51 enum class Severity { s_InfoVerbose , s_InfoSummary , s_Debug , s_Warning , s_Error , s_Assertion } ;
53 Log( Severity ,
const char * file ,
int line ) ;
62 std::ostream &
operator<<(
const std::string & s ) ;
65 static bool at( Severity ) ;
70 static bool at( Severity ,
const char * group ) ;
74 Log(
const Log & ) = delete ;
76 void operator=(
const Log & ) = delete ;
77 void operator=(
Log && ) = delete ;
86 std::ostream & m_ostream ;
97#define G_LOG_IMP( expr , severity ) do { try { if(G::Log::at(severity)) G::Log((severity),__FILE__,__LINE__) << expr ; } catch(...) {} } while(0)
98#define G_LOG_IMP_IF( cond , expr , severity ) do { try { if(G::Log::at(severity)&&(cond)) G::Log((severity),__FILE__,__LINE__) << expr ; } catch(...) {} } while(0)
99#define G_LOG_IMP_ONCE( expr , severity ) do { static bool done__ = false ; try { if(!done__) G::Log((severity),__FILE__,__LINE__) << expr ; } catch(...) {} done__ = true ; } while(0)
101#if defined(G_WITH_DEBUG) || ( defined(_DEBUG) && ! defined(G_NO_DEBUG) )
102#define G_DEBUG( expr ) G_LOG_IMP( expr , G::Log::Severity::s_Debug )
103#define G_DEBUG_IF( cond , expr ) G_LOG_IMP_IF( cond , expr , G::Log::Severity::s_Debug )
104#define G_DEBUG_ONCE( expr ) G_LOG_IMP_ONCE( expr , G::Log::Severity::s_Debug )
106#define G_DEBUG( expr )
107#define G_DEBUG_IF( cond , expr )
108#define G_DEBUG_ONCE( group , expr )
111#if ! defined(G_NO_LOG)
112#define G_LOG( expr ) G_LOG_IMP( expr , G::Log::Severity::s_InfoVerbose )
113#define G_LOG_IF( cond , expr ) G_LOG_IMP_IF( cond , expr , G::Log::Severity::s_InfoVerbose )
114#define G_LOG_ONCE( expr ) G_LOG_IMP_ONCE( expr , G::Log::Severity::s_InfoVerbose )
117#define G_LOG_IF( cond , expr )
118#define G_LOG_ONCE( expr )
121#if ! defined(G_NO_LOG_S)
122#define G_LOG_S( expr ) G_LOG_IMP( expr , G::Log::Severity::s_InfoSummary )
123#define G_LOG_S_IF( cond , expr ) G_LOG_IMP_IF( cond , expr , G::Log::Severity::s_InfoSummary )
124#define G_LOG_S_ONCE( expr ) G_LOG_IMP_ONCE( expr , G::Log::Severity::s_InfoSummary )
126#define G_LOG_S( expr )
127#define G_LOG_S_IF( cond , expr )
128#define G_LOG_S_ONCE( expr )
131#if ! defined(G_NO_WARNING)
132#define G_WARNING( expr ) G_LOG_IMP( expr , G::Log::Severity::s_Warning )
133#define G_WARNING_ONCE( expr ) G_LOG_IMP_ONCE( expr , G::Log::Severity::s_Warning )
135#define G_WARNING( expr )
136#define G_WARNING_ONCE( expr )
139#if ! defined(G_NO_ERROR)
140#define G_ERROR( expr ) G_LOG_IMP( expr , G::Log::Severity::s_Error )
142#define G_ERROR( expr )
A class for doing iostream-based logging.
~Log()
Destructor. Writes the accumulated string to the log output.
std::ostream & operator<<(const char *s)
Streams 's' and then returns a stream for streaming more stuff into.
static bool at(Severity, const char *group)
An overload that adds a logging group name to the test.
Log(Severity, const char *file, int line)
Constructor.
static bool at(Severity)
Returns true if G::LogOutput::output() would log at the given level.