libzypp  15.28.6
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 #else
23 namespace zypp
24 {
25  namespace debug
26  {
27  void osdlog( const std::string & msg_r, unsigned level_r ); // LogControl.cc
28  }
29 }
30 #define OSDLOG( MSG ) ::zypp::debug::osdlog( MSG, 0 )
31 #define OSMLOG( L, MSG ) ::zypp::debug::osdlog( MSG, L )
32 #endif // ZYPP_NDEBUG
33 
56 
57 #ifndef ZYPP_BASE_LOGGER_LOGGROUP
58 
59 #define ZYPP_BASE_LOGGER_LOGGROUP "DEFINE_LOGGROUP"
60 #endif
61 
62 #define XXX L_XXX( ZYPP_BASE_LOGGER_LOGGROUP )
63 #define DBG L_DBG( ZYPP_BASE_LOGGER_LOGGROUP )
64 #define MIL L_MIL( ZYPP_BASE_LOGGER_LOGGROUP )
65 #define WAR L_WAR( ZYPP_BASE_LOGGER_LOGGROUP )
66 #define ERR L_ERR( ZYPP_BASE_LOGGER_LOGGROUP )
67 #define SEC L_SEC( ZYPP_BASE_LOGGER_LOGGROUP )
68 #define INT L_INT( ZYPP_BASE_LOGGER_LOGGROUP )
69 #define USR L_USR( ZYPP_BASE_LOGGER_LOGGROUP )
70 
71 #define L_XXX(GROUP) ZYPP_BASE_LOGGER_LOG( GROUP, zypp::base::logger::E_XXX )
72 #define L_DBG(GROUP) ZYPP_BASE_LOGGER_LOG( GROUP"++", zypp::base::logger::E_MIL )
73 #define L_MIL(GROUP) ZYPP_BASE_LOGGER_LOG( GROUP, zypp::base::logger::E_MIL )
74 #define L_WAR(GROUP) ZYPP_BASE_LOGGER_LOG( GROUP, zypp::base::logger::E_WAR )
75 #define L_ERR(GROUP) ZYPP_BASE_LOGGER_LOG( GROUP, zypp::base::logger::E_ERR )
76 #define L_SEC(GROUP) ZYPP_BASE_LOGGER_LOG( GROUP, zypp::base::logger::E_SEC )
77 #define L_INT(GROUP) ZYPP_BASE_LOGGER_LOG( GROUP, zypp::base::logger::E_INT )
78 #define L_USR(GROUP) ZYPP_BASE_LOGGER_LOG( GROUP, zypp::base::logger::E_USR )
79 
80 #define L_BASEFILE ( *__FILE__ == '/' ? strrchr( __FILE__, '/' ) + 1 : __FILE__ )
81 
83 #define ZYPP_BASE_LOGGER_LOG(GROUP,LEVEL) \
84  zypp::base::logger::getStream( GROUP, LEVEL, L_BASEFILE, __FUNCTION__, __LINE__ )
85 
88 namespace zypp
90 {
91  namespace base
93  {
94 
96  namespace logger
97  {
98 
103  enum LogLevel {
104  E_XXX = 999,
105  E_DBG = 0,
112  };
113 
124  extern std::ostream & getStream( const char * group_r,
125  LogLevel level_r,
126  const char * file_r,
127  const char * func_r,
128  const int line_r );
129  extern bool isExcessive();
130 
132  } // namespace logger
134 
136  } // namespace base
139 } // namespace zypp
141 #endif // ZYPP_BASE_LOGGER_H
Internal error.
Definition: Logger.h:110
LogLevel
Definition of log levels.
Definition: Logger.h:103
Debug or verbose.
Definition: Logger.h:105
void osdlog(const std::string &msg_r, unsigned level_r)
Definition: LogControl.cc:32
Secutrity related.
Definition: Logger.h:109
Excessive logging.
Definition: Logger.h:104
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:408