VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
G::LogOutput Class Reference

Controls and implements low-level logging output, as used by the Log interface. More...

#include <glogoutput.h>

Public Types

enum  SyslogFacility { User, Daemon, Mail, Cron }
 

Public Member Functions

 LogOutput (const std::string &prefix, bool output, bool with_logging, bool with_verbose_logging, bool with_debug, bool with_level, bool with_timestamp, bool strip_context, bool use_syslog, const std::string &stderr_replacement=std::string(), SyslogFacility syslog_facility=User)
 Constructor. More...
 
 LogOutput (bool output_with_logging, bool verbose_and_debug=true, const std::string &stderr_replacement=std::string())
 Constructor for test programs. More...
 
virtual ~LogOutput ()
 Destructor.
 
virtual void rawOutput (std::ostream &, G::Log::Severity, const std::string &)
 Overridable. More...
 
bool enable (bool enabled=true)
 Enables or disables output. Returns the previous setting.
 
void verbose (bool verbose_log=true)
 Enables or disables verbose logging.
 
bool at (G::Log::Severity) const
 Returns true if output() generates output at the given severity level.
 
bool syslog () const
 Returns true if syslog output is enabled.
 
virtual void onAssert ()
 Called during an assertion failure. More...
 

Static Public Member Functions

static LogOutputinstance ()
 Returns a pointer to the controlling LogOutput object. More...
 
static void output (G::Log::Severity, const char *file, int line, const std::string &)
 Generates output if there is an existing LogOutput object which is enabled. More...
 
static void assertion (const char *file, int line, bool test, const char *)
 Makes an assertion check (regardless of any LogOutput object). More...
 

Detailed Description

Controls and implements low-level logging output, as used by the Log interface.

Applications should instantiate a LogOutput object in main() to enable log output.

See Also
G::Log

Definition at line 41 of file glogoutput.h.

Constructor & Destructor Documentation

G::LogOutput::LogOutput ( const std::string &  prefix,
bool  output,
bool  with_logging,
bool  with_verbose_logging,
bool  with_debug,
bool  with_level,
bool  with_timestamp,
bool  strip_context,
bool  use_syslog,
const std::string &  stderr_replacement = std::string(),
SyslogFacility  syslog_facility = User 
)

Constructor.

If there is no LogOutput object, or if 'output' is false, then there is no output of any sort. Otherwise at least warning and error messages are generated.

If 'with-logging' is true then log[summary] messages are output. If 'with-verbose-logging' is true then log[verbose] messages are output. If 'with_debug' is true then debug messages will also be generated (but only if compiled in).

More than one LogOutput object may be created, but only the first one controls output.

Definition at line 33 of file glogoutput.cpp.

G::LogOutput::LogOutput ( bool  output_with_logging,
bool  verbose_and_debug = true,
const std::string &  stderr_replacement = std::string() 
)
explicit

Constructor for test programs.

Only generates output if the first parameter is true. Never uses syslog.

Definition at line 56 of file glogoutput.cpp.

Member Function Documentation

void G::LogOutput::assertion ( const char *  file,
int  line,
bool  test,
const char *  test_string 
)
static

Makes an assertion check (regardless of any LogOutput object).

Calls output() if the 'file' parameter is not null.

Definition at line 249 of file glogoutput.cpp.

G::LogOutput * G::LogOutput::instance ( )
static

Returns a pointer to the controlling LogOutput object.

Returns nullptr if none.

Definition at line 109 of file glogoutput.cpp.

void G::LogOutput::onAssert ( )
virtual

Called during an assertion failure.

This allows Windows applications to stop timers etc. (Timers can cause reentrancy problems and infinitely recursive dialog box creation.)

Definition at line 193 of file glogoutput.cpp.

void G::LogOutput::output ( G::Log::Severity  severity,
const char *  file,
int  line,
const std::string &  text 
)
static

Generates output if there is an existing LogOutput object which is enabled.

Uses rawOutput().

Definition at line 126 of file glogoutput.cpp.

void G::LogOutput::rawOutput ( std::ostream &  std_err,
G::Log::Severity  severity,
const std::string &  message 
)
virtual

Overridable.

Used to do the final message output (with OutputDebugString() or stderr).

Definition at line 51 of file glogoutput_unix.cpp.


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