E-MailRelay
Public Types | Public Member Functions | Static Public Member Functions | List of all members
G::Log Class Reference

A class for doing iostream-based logging. More...

#include <glog.h>

Public Types

enum class  Severity {
  Debug , InfoMoreVerbose , InfoVerbose , InfoSummary ,
  Warning , Error , Assertion
}
 

Public Member Functions

 Log (Severity, const char *file, int line) noexcept
 Constructor. More...
 
 ~Log ()
 Destructor. Writes the accumulated string to the log output. More...
 
LogStreamoperator<< (const char *s) noexcept
 Streams 's' and then returns a stream for streaming more stuff into. More...
 
LogStreamoperator<< (const std::string &s) noexcept
 Streams 's' and then returns a stream for streaming more stuff into. More...
 
LogStreamoperator<< (const format &f)
 Streams 'f' and then returns a stream for streaming more stuff into. More...
 
 Log (const Log &)=delete
 
 Log (Log &&)=delete
 
Logoperator= (const Log &)=delete
 
Logoperator= (Log &&)=delete
 

Static Public Member Functions

static bool at (Severity) noexcept
 Returns true if G::LogOutput::output() would log at the given level. More...
 
static bool atDebug () noexcept
 Returns at(Severity::Debug). More...
 
static bool atVerbose () noexcept
 Returns at(Severity::InfoVerbose). More...
 
static bool atMoreVerbose () noexcept
 Returns at(Severity::InfoMoreVerbose). More...
 

Detailed Description

A class for doing iostream-based logging.

The G_LOG/G_DEBUG/G_WARNING/G_ERROR macros are provided as a convenient way of using this interface.

Usage:

G::Log(G::Log::Severity::InfoSummary,__FILE__,__LINE__) << a << b ;
A class for doing iostream-based logging.
Definition: glog.h:55

or

G_LOG( a << b ) ;

or

G_LOG( G::format("%1% %2%") % a % b ) ;
A simple version of boost::format for formatting strings in an i18n-friendly way.
Definition: gformat.h:46
See also
G::LogOutput

Definition at line 54 of file glog.h.

Member Enumeration Documentation

◆ Severity

enum class G::Log::Severity
strong

Definition at line 57 of file glog.h.

Constructor & Destructor Documentation

◆ Log()

G::Log::Log ( Severity  severity,
const char *  file,
int  line 
)
noexcept

Constructor.

Definition at line 26 of file glog.cpp.

◆ ~Log()

G::Log::~Log ( )

Destructor. Writes the accumulated string to the log output.

Definition at line 35 of file glog.cpp.

Member Function Documentation

◆ at()

bool G::Log::at ( Severity  s)
staticnoexcept

Returns true if G::LogOutput::output() would log at the given level.

This can be used as an optimisation to short-ciruit the stream-out expression evaluation.

Definition at line 41 of file glog.cpp.

◆ atDebug()

bool G::Log::atDebug ( )
inlinestaticnoexcept

Returns at(Severity::Debug).

Definition at line 113 of file glog.h.

◆ atMoreVerbose()

bool G::Log::atMoreVerbose ( )
inlinestaticnoexcept

Returns at(Severity::InfoMoreVerbose).

Definition at line 123 of file glog.h.

◆ atVerbose()

bool G::Log::atVerbose ( )
inlinestaticnoexcept

Returns at(Severity::InfoVerbose).

Definition at line 118 of file glog.h.

◆ operator<<() [1/3]

G::LogStream & G::Log::operator<< ( const char *  s)
noexcept

Streams 's' and then returns a stream for streaming more stuff into.

Definition at line 50 of file glog.cpp.

◆ operator<<() [2/3]

G::LogStream & G::Log::operator<< ( const format f)

Streams 'f' and then returns a stream for streaming more stuff into.

Definition at line 66 of file glog.cpp.

◆ operator<<() [3/3]

G::LogStream & G::Log::operator<< ( const std::string &  s)
noexcept

Streams 's' and then returns a stream for streaming more stuff into.

Definition at line 58 of file glog.cpp.


The documentation for this class was generated from the following files: