ArmarXFileLogger.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarXCore::ArmarXObjects::ArmarXFileLogger
17 * @author Mirko Waechter ( mirko dot waechter at kit dot edu )
18 * @date 2017
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#pragma once
24
25
26#include <fstream>
27#include <mutex>
28
30#include <ArmarXCore/interface/core/Log.h>
31
32namespace armarx
33{
34 /**
35 * @class ArmarXFileLoggerPropertyDefinitions
36 * @brief
37 */
43
44 /**
45 * @defgroup Component-ArmarXFileLogger ArmarXFileLogger
46 * @ingroup ArmarXCore-Components
47 * A description of the component ArmarXFileLogger.
48 *
49 * @class ArmarXFileLogger
50 * @ingroup Component-ArmarXFileLogger
51 * @brief Brief description of class ArmarXFileLogger.
52 *
53 * Detailed description of class ArmarXFileLogger.
54 */
55 class ArmarXFileLogger : virtual public armarx::Component, public Log
56 {
57 public:
58 std::string getDefaultName() const override;
59
60 // Log interface
61 void writeLog(const LogMessage&, const Ice::Current&) override;
62
63
64 protected:
66 void onInitComponent() override;
67 void onConnectComponent() override;
68 void onDisconnectComponent() override;
69 void onExitComponent() override;
70
71 std::vector<std::string> getDirListOrderedByDate(const std::string& dir) const;
72 std::string getNextLogFileNameAndDeleteOldFiles(const std::string& dir,
73 int maxLogFileCount,
74 const std::string& fileBasename,
75 const std::string& fileNameEnding) const;
76
77 std::ofstream fileStream;
79 std::map<std::string, std::shared_ptr<std::ofstream>> applicationFileStreams;
80 std::mutex mutex;
81 };
82} // namespace armarx
Brief description of class ArmarXFileLogger.
std::string applicationsLogFileBasePath
void onInitComponent() override
Pure virtual hook for the subclass.
std::vector< std::string > getDirListOrderedByDate(const std::string &dir) const
void onDisconnectComponent() override
Hook for subclass.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Creates the property definition container.
void onConnectComponent() override
Pure virtual hook for the subclass.
void writeLog(const LogMessage &, const Ice::Current &) override
std::map< std::string, std::shared_ptr< std::ofstream > > applicationFileStreams
std::string getNextLogFileNameAndDeleteOldFiles(const std::string &dir, int maxLogFileCount, const std::string &fileBasename, const std::string &fileNameEnding) const
void onExitComponent() override
Hook for subclass.
std::string getDefaultName() const override
Retrieve default name of component.
Default component property definition container.
Definition Component.h:70
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.