libzypp  17.8.0
Logger.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_BASE_LOGGER_H
13 #define ZYPP_BASE_LOGGER_H
14 #include <cstring>
15 #include <iosfwd>
16 #include <string>
17 
19 #ifdef ZYPP_NDEBUG
20 #define OSDLOG( MSG )
21 #define OSMLOG( L, MSG )
22 #define TRACELEAVE
23 #else
24 namespace zypp
25 {
26  namespace debug
27  {
28  void osdlog( const std::string & msg_r, unsigned level_r ); // LogControl.cc
29 
30  struct TraceLeave // LogControl.cc
31  {
32  TraceLeave( const TraceLeave & ) =delete;
33  TraceLeave & operator=( const TraceLeave & ) =delete;
34  TraceLeave( const char * file_r, const char * fnc_r, int line_r );
35  ~TraceLeave();
36  private:
37  static unsigned _depth;
38  const char * _file;
39  const char * _fnc;
40  int _line;
41  };
42  }
43 }
44 #define OSDLOG( MSG ) ::zypp::debug::osdlog( MSG, 0 )
45 #define OSMLOG( L, MSG ) ::zypp::debug::osdlog( MSG, L )
46 #define TRACELEAVE ::zypp::debug::TraceLeave _TraceLeave( __FILE__, __FUNCTION__, __LINE__ )
47 #endif // ZYPP_NDEBUG
48 
71 
72 #ifndef ZYPP_BASE_LOGGER_LOGGROUP
73 
74 #define ZYPP_BASE_LOGGER_LOGGROUP "DEFINE_LOGGROUP"
75 #endif
76 
77 #define XXX L_XXX( ZYPP_BASE_LOGGER_LOGGROUP )
78 #define DBG L_DBG( ZYPP_BASE_LOGGER_LOGGROUP )
79 #define MIL L_MIL( ZYPP_BASE_LOGGER_LOGGROUP )
80 #define WAR L_WAR( ZYPP_BASE_LOGGER_LOGGROUP )
81 #define ERR L_ERR( ZYPP_BASE_LOGGER_LOGGROUP )
82 #define SEC L_SEC( ZYPP_BASE_LOGGER_LOGGROUP )
83 #define INT L_INT( ZYPP_BASE_LOGGER_LOGGROUP )
84 #define USR L_USR( ZYPP_BASE_LOGGER_LOGGROUP )
85 
86 #define L_XXX(GROUP) ZYPP_BASE_LOGGER_LOG( GROUP, zypp::base::logger::E_XXX )
87 #define L_DBG(GROUP) ZYPP_BASE_LOGGER_LOG( GROUP"++", zypp::base::logger::E_MIL )
88 #define L_MIL(GROUP) ZYPP_BASE_LOGGER_LOG( GROUP, zypp::base::logger::E_MIL )
89 #define L_WAR(GROUP) ZYPP_BASE_LOGGER_LOG( GROUP, zypp::base::logger::E_WAR )
90 #define L_ERR(GROUP) ZYPP_BASE_LOGGER_LOG( GROUP, zypp::base::logger::E_ERR )
91 #define L_SEC(GROUP) ZYPP_BASE_LOGGER_LOG( GROUP, zypp::base::logger::E_SEC )
92 #define L_INT(GROUP) ZYPP_BASE_LOGGER_LOG( GROUP, zypp::base::logger::E_INT )
93 #define L_USR(GROUP) ZYPP_BASE_LOGGER_LOG( GROUP, zypp::base::logger::E_USR )
94 
95 #define L_BASEFILE ( *__FILE__ == '/' ? strrchr( __FILE__, '/' ) + 1 : __FILE__ )
96 
98 #define ZYPP_BASE_LOGGER_LOG(GROUP,LEVEL) \
99  zypp::base::logger::getStream( GROUP, LEVEL, L_BASEFILE, __FUNCTION__, __LINE__ )
100 
103 namespace zypp
105 {
106  namespace base
108  {
109 
111  namespace logger
112  {
113 
118  enum LogLevel {
119  E_XXX = 999,
120  E_DBG = 0,
127  };
128 
139  extern std::ostream & getStream( const char * group_r,
140  LogLevel level_r,
141  const char * file_r,
142  const char * func_r,
143  const int line_r );
144  extern bool isExcessive();
145 
147  } // namespace logger
149 
151  } // namespace base
154 } // namespace zypp
156 #endif // ZYPP_BASE_LOGGER_H
Internal error.
Definition: Logger.h:125
LogLevel
Definition of log levels.
Definition: Logger.h:118
Debug or verbose.
Definition: Logger.h:120
TraceLeave & operator=(const TraceLeave &)=delete
void osdlog(const std::string &msg_r, unsigned level_r)
Definition: LogControl.cc:32
Secutrity related.
Definition: Logger.h:124
const char * _fnc
Definition: Logger.h:39
TraceLeave(const TraceLeave &)=delete
static unsigned _depth
Definition: Logger.h:37
const char * _file
Definition: Logger.h:38
Excessive logging.
Definition: Logger.h:119
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
std::ostream & getStream(const char *group_r, LogLevel level_r, const char *file_r, const char *func_r, const int line_r)
Return a log stream to write on.
Definition: LogControl.cc:425