Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

Y2SLog.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013    File:       Y2SLog.h
00014 
00015    Author:     Michael Andres <ma@suse.de>
00016    Maintainer: Michael Andres <ma@suse.de>
00017 
00018 /-*/
00019 #ifndef Y2SLog_h
00020 #define Y2SLog_h
00021 
00022 #include <iostream>
00023 
00024 // Don't know why y2log.h insists on having a component name
00025 // defined and throws an error if it's missing.
00026 // However, I want Y2SLog to work out of the box.
00027 #ifndef Y2LOG
00028 #define Y2LOG "DEFINE_Y2LOG"
00029 #endif
00030 
00031 #include <y2util/y2log.h>
00032 
00034 //
00035 namespace Y2SLog {
00036 //
00038 
00039 extern bool dbg_enabled_bm;
00040 
00041 extern std::ostream & get( const char * which, const unsigned level,
00042                            const char * fil, const char * fnc, const int lne );
00043 
00044 extern std::ostream & getdbg( const char * which, const unsigned level,
00045                               const char * fil, const char * fnc, const int lne );
00046 
00047 } // namespace Y2SLog
00049 
00050 #define _Y2SLOG(c,l)    Y2SLog::get( c, l, __FILE__, __FUNCTION__, __LINE__ )
00051 #define _Y2SLOD(c,l)    Y2SLog::get( c"++", 1, __FILE__, __FUNCTION__, __LINE__ )
00052 #define _Y2SLOGDBG(c,l) Y2SLog::getdbg( c"-dbg", l, __FILE__, __FUNCTION__, __LINE__ )
00053 #define _Y2SLODDBG(c,l) Y2SLog::getdbg( c"-dbg++", 1, __FILE__, __FUNCTION__, __LINE__ )
00054 
00055 //
00056 // To log to component 'foo' write:
00057 //
00058 //        _DBG("foo") << ....
00059 // or
00060 //        #define Y2LOG "foo"
00061 //        DBG << ....
00062 //
00063 
00064 #define _DBG(c) _Y2SLOD( c, 0 )
00065 #define _MIL(c) _Y2SLOG( c, 1 )
00066 #define _WAR(c) _Y2SLOG( c, 2 )
00067 #define _ERR(c) _Y2SLOG( c, 3 )
00068 #define _SEC(c) _Y2SLOG( c, 4 )
00069 #define _INT(c) _Y2SLOG( c, 5 )
00070 
00071 #define DBG _DBG(Y2LOG)
00072 #define MIL _MIL(Y2LOG)
00073 #define WAR _WAR(Y2LOG)
00074 #define ERR _ERR(Y2LOG)
00075 #define SEC _SEC(Y2LOG)
00076 #define INT _INT(Y2LOG)
00077 
00078 //
00079 // To enable debug output (using component 'foo-dbg'), set 'Y2SLog::dbg_enabled_bm = true;'.
00080 // Unless the environmental variable Y2SLOG_DEBUG is defined (with arbitrary value),
00081 // debug output is disabled by default.
00082 //
00083 //        _D__("foo") << ....
00084 //
00085 //        #define Y2LOG "foo"
00086 //        D__ << ....
00087 //
00088 #define _D__(c) _Y2SLODDBG( c, 0 )
00089 #define _M__(c) _Y2SLOGDBG( c, 1 )
00090 #define _W__(c) _Y2SLOGDBG( c, 2 )
00091 #define _E__(c) _Y2SLOGDBG( c, 3 )
00092 #define _S__(c) _Y2SLOGDBG( c, 4 )
00093 #define _I__(c) _Y2SLOGDBG( c, 5 )
00094 
00095 #define D__ _D__(Y2LOG)
00096 #define M__ _M__(Y2LOG)
00097 #define W__ _W__(Y2LOG)
00098 #define E__ _E__(Y2LOG)
00099 #define S__ _S__(Y2LOG)
00100 #define I__ _I__(Y2LOG)
00101 
00103 
00104 #endif // Y2SLog_h

Generated on Thu Feb 23 23:56:10 2006 for liby2util by doxygen 1.3.6