FileLoggingStrategy.h
Go to the documentation of this file.
1#pragma once
2
3/*
4 * This file is part of ArmarX.
5 *
6 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
7 *
8 * ArmarX is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * ArmarX is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * @package ArmarXCore::core::services::profiler
21 * @author Manfred Kroehnert ( manfred dot kroehnert at dot kit dot edu )
22 * @date 2015
23 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
24 * GNU General Public License
25 */
26
27
28#include <mutex>
29#include <vector>
30
31#include "LoggingStrategy.h"
32
33namespace armarx::Profiler
34{
36 using FileLoggingStrategyPtr = std::shared_ptr<FileLoggingStrategy>;
37
38 /**
39 * @class FileLoggingStrategy
40 * @ingroup Profiling
41 * @brief A brief description
42 *
43 * Detailed Description
44 */
45 class FileLoggingStrategy : virtual public LoggingStrategy
46 {
47 public:
49
50 ~FileLoggingStrategy() override;
51
52 void logEvent(pid_t processId,
53 uint64_t timestamp,
54 const std::string& executableName,
55 const std::string& timestampUnit,
56 const std::string& eventName,
57 const std::string& parentName,
58 const std::string& functionName) override;
59
60 private:
61 void writeFile();
62 void writeHeader(std::ostream& outputStream);
63
64 std::mutex mutex;
65 std::vector<std::string> eventList;
66 };
67} // namespace armarx::Profiler
std::string timestamp()
void logEvent(pid_t processId, uint64_t timestamp, const std::string &executableName, const std::string &timestampUnit, const std::string &eventName, const std::string &parentName, const std::string &functionName) override
std::shared_ptr< FileLoggingStrategy > FileLoggingStrategyPtr