Teamcenter C++ API Reference  2312
tclogging/Logger.hxx
Go to the documentation of this file.
1 // Copyright 2022 Siemens Digital Industries Software
2 // ==================================================
3 // Copyright 2022.
4 // Siemens Product Lifecycle Management Software Inc.
5 // All Rights Reserved.
6 // ==================================================
7 // Copyright 2022 Siemens Digital Industries Software
8 
9 
10 
11 
12 #ifndef TEAMCENTER_COMMON_LOGGING_LOGGER_HXX
13 #define TEAMCENTER_COMMON_LOGGING_LOGGER_HXX
14 
15 #include <string>
16 
17 
18 
19 
20 #include <tclogging/libtclogging_exports.h>
21 
22 
23 
24 namespace Teamcenter::Common::Logging
25 {
26  class Appender;
27 
29  enum class LogLevel { LOG_TRACE = 1, LOG_DEBUG = 2, LOG_INFO = 3, LOG_WARN = 4, LOG_ERROR = 5, LOG_OFF = 6 };
30 
34  class TCLOGGING_API Logger
35  {
36  public:
37 
38  static std::string ROOT_LOGGER_NAME;
40 
41  virtual ~Logger() = default;
42  Logger() = delete;
43  Logger( const Logger& ) = delete;
44  Logger( Logger&& ) = delete;
45  Logger& operator=( const Logger& ) = delete;
46  Logger& operator=( Logger&& ) = delete;
47  private:
48  friend class TcLogManager;
49  Logger( const std::string& name, Appender* appender, LogLevel lvl );
50  public:
51 
52 
53 
54 
56  std::string getLoggerName() const;
57 
63  void setLogLevel( LogLevel lvl );
64 
70  LogLevel getLogLevel() const;
71 
73  bool isTraceEnabled() const;
75  bool isDebugEnabled() const;
77  bool isInfoEnabled() const;
79  bool isWarnEnabled() const;
81  bool isErrorEnabled() const;
82 
83 
84 
90  void error( const std::string& msg );
91 
98  void error( const int errorCode, const std::string& msg );
99 
109  void error( const char* file, const int line, const int errorCode, const std::string& msg );
110 
116  void warn( const std::string& msg );
117 
124  void warn( const int errorCode, const std::string& msg );
125 
134  void warn( const char* file, const int line, const int errorCode, const std::string& msg );
135 
141  void info( const std::string& msg );
142 
143 
144 
150  void debug( const std::string& msg );
151 
152 
153 
159  void trace( const std::string& msg );
160 
161 
162 
167  Appender* getAppender();
168 
169 
170  private:
171 
172  std::string loggerName;
175 
176  };
177 
178 }
179 
180 #include <tclogging/libtclogging_undef.h>
181 #endif