51 enum Severity { s_LogVerbose , s_LogSummary , s_Debug , s_Warning , s_Error , s_Assertion } ;
54 {
public:
const char * m_file ;
int m_line ;
Line(
const char *file ,
int line ) : m_file(file) , m_line(line) {} } ;
56 Log( Severity ,
const char * file ,
int line ) ;
65 std::ostream &
operator<<(
const std::string & s ) ;
68 static bool at( Severity ) ;
80 std::ostringstream m_ss ;
92 #define G_LOG_OUTPUT( expr , severity ) do { if(G::Log::at(severity)) G::Log(severity,__FILE__,__LINE__) << expr ; } while(0)
93 #if defined(G_WITH_DEBUG) || ( defined(_DEBUG) && ! defined(G_NO_DEBUG) )
94 #define G_DEBUG( expr ) G_LOG_OUTPUT( expr , G::Log::s_Debug )
96 #define G_DEBUG( expr )
98 #if ! defined(G_NO_LOG)
99 #define G_LOG( expr ) G_LOG_OUTPUT( expr , G::Log::s_LogVerbose )
101 #define G_LOG( expr )
103 #if ! defined(G_NO_LOG_S)
104 #define G_LOG_S( expr ) G_LOG_OUTPUT( expr , G::Log::s_LogSummary )
106 #define G_LOG_S( expr )
108 #if ! defined(G_NO_WARNING)
109 #define G_WARNING( expr ) G_LOG_OUTPUT( expr , G::Log::s_Warning )
110 #define G_WARNING_ONCE( expr ) do { static bool warned=false; if(!warned) G_LOG_OUTPUT(expr,G::Log::s_Warning); warned=true; } while(0)
112 #define G_WARNING( expr )
113 #define G_WARNING_ONCE( expr )
115 #if ! defined(G_NO_ERROR)
116 #define G_ERROR( expr ) G_LOG_OUTPUT( expr , G::Log::s_Error )
118 #define G_ERROR( expr )
A class for adding line number information to the Log output.
static bool at(Severity)
Returns true if G::LogOutput::output() would log at the given level.
Log(Severity, const char *file, int line)
Constructor.
A class for doing iostream-based logging.
std::ostream & operator<<(const char *s)
Streams 's' and then returns a stream for streaming more stuff into.
~Log()
Destructor. Writes the accumulated string to the log output.