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 
32 namespace armarx
33 {
34  /**
35  * @class ArmarXFileLoggerPropertyDefinitions
36  * @brief
37  */
39  {
40  public:
42  };
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
armarx::ArmarXFileLogger::fileStream
std::ofstream fileStream
Definition: ArmarXFileLogger.h:77
armarx::ArmarXFileLogger::writeLog
void writeLog(const LogMessage &, const Ice::Current &) override
Definition: ArmarXFileLogger.cpp:237
armarx::ArmarXFileLogger::applicationsLogFileBasePath
std::string applicationsLogFileBasePath
Definition: ArmarXFileLogger.h:78
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
armarx::ArmarXFileLoggerPropertyDefinitions
Definition: ArmarXFileLogger.h:38
armarx::ArmarXFileLogger::getNextLogFileNameAndDeleteOldFiles
std::string getNextLogFileNameAndDeleteOldFiles(const std::string &dir, int maxLogFileCount, const std::string &fileBasename, const std::string &fileNameEnding) const
Definition: ArmarXFileLogger.cpp:186
armarx::ArmarXFileLogger::getDirListOrderedByDate
std::vector< std::string > getDirListOrderedByDate(const std::string &dir) const
Definition: ArmarXFileLogger.cpp:157
armarx::ArmarXFileLogger::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: ArmarXFileLogger.cpp:136
armarx::ArmarXFileLogger::mutex
std::mutex mutex
Definition: ArmarXFileLogger.h:80
armarx::ArmarXFileLogger::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Creates the property definition container.
Definition: ArmarXFileLogger.cpp:150
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::ArmarXFileLogger::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: ArmarXFileLogger.cpp:131
armarx::ArmarXFileLogger::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: ArmarXFileLogger.cpp:231
armarx::ArmarXFileLoggerPropertyDefinitions::ArmarXFileLoggerPropertyDefinitions
ArmarXFileLoggerPropertyDefinitions(std::string prefix)
Definition: ArmarXFileLogger.cpp:36
armarx::ArmarXFileLogger::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: ArmarXFileLogger.cpp:145
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::ArmarXFileLogger::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: ArmarXFileLogger.cpp:59
armarx::ArmarXFileLogger::applicationFileStreams
std::map< std::string, std::shared_ptr< std::ofstream > > applicationFileStreams
Definition: ArmarXFileLogger.h:79
armarx::ArmarXFileLogger
Brief description of class ArmarXFileLogger.
Definition: ArmarXFileLogger.h:55
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28