source: trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Logger/Logger.h @ 61

Last change on this file since 61 was 22, checked in by rings, 14 years ago
  • Property svn:executable set to *
File size: 3.8 KB
Line 
1/**
2 * @file Logger.h
3 * Defines the Logger class
4 * @author Tomas Urban
5 * @version 0.2
6 * @date 23/07/2009
7 */
8#ifndef LOGGER_H
9#define LOGGER_H
10
11#include <boost/thread/mutex.hpp>
12#include "Helper/Singleton.h"
13
14/**
15 * Singleton class for logging. The class uses std::clog as the output channel. All logging
16 * operations are thread safe.
17 */
18class Logger : public Singleton<Logger>
19{
20private:
21        friend class Singleton<Logger>;
22        Logger(void);
23        int m_nLogMode; // Logging mode
24        boost::mutex m_mutex; // Logging lock
25        void LogLine(const std::string sText);
26public:
27        ~Logger(void); 
28
29        /**
30         * No logging operations are with exeption allowed when this mode is set. It should not be combined
31         * with other modes.
32         */
33        static const int LOG_NOTHING = 0x00;
34        /**
35          * Important information statements are allowed to be printed to the log when this
36          * mode is active. This mode can be combined with other modes. It is one of the default
37          * modes.
38         */
39        static const int LOG_INFO = 0x01;
40        /**
41          * Critical errors are allowed to be printed to the log when this mode is active. This
42          * mode can be combined with other modes. It is one of the default modes.
43         */
44        static const int LOG_ERRORS = 0x02;
45        /**
46          * Minor warnings are allowed to be printed to the log when this mode is active. This
47          * mode can be combined with other modes.
48         */
49        static const int LOG_WARNINGS = 0x04;
50        /**
51          * Hexa dump of captured messages is allowed to be printed to the log when this mode
52          * is active. This mode can be combined with other modes.
53         */
54        static const int LOG_CAPTURE = 0x08;
55        /**
56          * Debugging statements are allowed to be printed to the log when this mode is active. This
57          * mode can be combined with other modes.
58         */
59        static const int LOG_DEBUG = 0x10;
60        /**
61         * All logging operations are allowed with this mode. It should not be combined with other
62         * modes.
63         */
64        static const int LOG_ALL = LOG_INFO | LOG_ERRORS | LOG_WARNINGS | LOG_CAPTURE | LOG_DEBUG;
65        /**
66         * Sets the logging mode. Individual logging methods are allowed to write to the logging output
67         * only if the particular logging mode is active.
68     *
69         * @param nMode Logging mode to be activated. Several modes can be combined using the bitwise or
70         *        operator. The following modes are provided:\n
71         *        #LOG_INFO\n
72         *        #LOG_ERRORS\n
73         *        #LOG_WARNINGS\n
74         *        #LOG_CAPTURE\n
75         *        #LOG_DEBUG\n
76         *        #LOG_NOTHING\n
77         *        #LOG_ALL
78         */
79        void SetLoggingMode(int nMode) { m_nLogMode = nMode; }
80        /**
81         * Returns the active logging mode. Individual logging methods are allowed to write to the
82         * logging output only if the particular logging mode is active.
83         *
84         * @return active logging mode
85         */
86        int GetLoggingMode() const { return m_nLogMode; }
87        /**
88         * Adds an informative statement to the log. #LOG_INFO mode has to be active, otherwise the
89         * method is not executed.
90         *
91         * @param sInfo information to be logged
92         */
93        void LogInfo(const std::string sInfo);
94        /**
95         * Adds an error statement to the log. #LOG_ERRORS mode has to be active, otherwise the
96         * method is not executed.
97         *
98         * @param sError error to be logged
99         */
100        void LogError(const std::string sError);
101        /**
102         * Adds a warning to the log. #LOG_WARNINGS mode has to be active, otherwise the
103         * method is not executed.
104         *
105         * @param sWarning warning to be logged
106         */
107        void LogWarning(const std::string sWarning);
108        /**
109         * Writes binary dump of captured data to the log. #LOG_CAPTURE mode has to be active,
110         * otherwise the method is not executed.
111         *
112         * @param sData captured data to be logged
113         */
114        void LogCapture(const std::string sData);
115        /**
116         * Adds a debugging statement to the log. #LOG_DEBUG mode has to be active, otherwise the
117         * method is not executed.
118         *
119         * @param sDebugData information to be logged
120         */
121        void LogDebug(const std::string sDebugData);
122};
123
124#endif
Note: See TracBrowser for help on using the repository browser.