CMS 3D CMS Logo

lat::logstream Class Reference

A logging stream. More...

#include <Iguana/Utilities/classlib/utils/Log.h>

List of all members.

Public Types

enum  State { Trace, Warning, Error }

Public Member Functions

bool deep (void) const
logstreamenable (bool value=true)
bool enabled (void) const
logstreamflush (void)
logstreamindent (int by=4)
 logstream (void)
logstreammode (logflag &flag, int level)
logstreamoperator<< (std::streambuf *buffer)
logstreamoperator<< (ios &(*fn)(ios &))
logstreamoperator<< (logstream &(*fn)(logstream &))
logstreamoperator<< (long double f)
logstreamoperator<< (float f)
logstreamoperator<< (double f)
logstreamoperator<< (unsigned short n)
logstreamoperator<< (short n)
logstreamoperator<< (unsigned long n)
logstreamoperator<< (long n)
logstreamoperator<< (unsigned int n)
logstreamoperator<< (int n)
logstreamoperator<< (const void *pointer)
logstreamoperator<< (const std::string &string)
logstreamoperator<< (const signed char *string)
logstreamoperator<< (const unsigned char *string)
logstreamoperator<< (const char *string)
logstreamoperator<< (signed char ch)
logstreamoperator<< (unsigned char ch)
logstreamoperator<< (char ch)
logstreamput (signed char ch)
logstreamput (unsigned char ch)
logstreamput (char ch)
logstreamrecurse (bool recursion=true)
logstreamregisterMode (logflag &mode)
logstreamselect (logflag &flag)
bool selected (void) const
logstreamstate (State value)
logstreamundent (int by=4)
logstreamunselect (logflag &flag)
virtual ~logstream (void)

Static Public Member Functions

static logstreamerror (logflag &mode, int level)
static logstreamlogger (void)
static logstreamtrace (logflag &mode, int level)
static logstreamwarning (logflag &mode, int level)

Protected Member Functions

virtual void emit (const char *string, int length)=0

Private Member Functions

void pad (int n)
void readjust (void)

Static Private Member Functions

static void checkMode (logflag &mode)
static logstreamcreateConsoleLogDevice (const char *args)
static logstreamcreateFileLogDevice (const char *args)
static logstreamcreateLocalSocketLogDevice (const char *args)
static logstreamcreatePipeLogDevice (const char *args)
static logstreamcreateSinkLogDevice (const char *args)
static logstreamcreateSocketLogDevice (bool local, bool tcp, const char *args)
static logstreamcreateStderrLogDevice (const char *args)
static logstreamcreateTcpSocketLogDevice (const char *args)
static logstreamcreateUdpSocketLogDevice (const char *args)

Private Attributes

buf * m_buf
 The logging output buffer.
bool m_deep
 A flag indicating that objects should dump their contents recursively.
bool m_enabled
 A flag indicating whether logging is enabled at all.
int m_indent
 The current indent level.
int m_longestModeName
 The length of the longest mode name seen so far.
bool m_longLineHeader
 A flag indicating whether the line header should be printed in the long format.
const logflagm_mode
 The current mode flag; defaults to LFall.
int m_modeNameLength
 The length of the current mode name.
bool m_newline
 Flag indicating whether the output is at the beginning of the line and the new line should prefixed and indented before actually outputting anything.
bool m_selected
 A flag indicating whether stream is in selected state, i.e., the current mode has been enabled and the level is chosen.
State m_state
 The current state (error, warning or trace).
std::ostream * m_stream
 The real output engine.

Static Private Attributes

static bool s_deleted
 A flag to indicate when the logging system has been destroyed.
static device s_devices []
 List of available logging devices.
static logflags_flags
 The chain of registered log flags (i.e., used so far).
static bool s_initialized
 A flag to indicate when the logging system has been initialized.
static logstreams_logger
 Pointer to the logging device used by the LOG() macros.

Friends

class buf


Detailed Description

A logging stream.

logstream selectively outputs the objects sent to it. The selection is done according to the current logging mode and level. It is also possible to enable and disabled the whole system separately from the modes. Output in a disabled mode is discarded.

There are several ways to control the logging behaviour. Firstly, the program can define default settings for the log flags and call the logstream methods. Secondly, the user can override the default settings from environment variables. Thirdly, the actual LOG() calls will selectively output the data. Finally, all the logging code can be compiled conditionally.

logstream interface is very similar to that of std::ostream. The left shift insertion operator can be used to send objects to the log. The standard stream manipulators work as usual. Polymorphic classes might wish to to inherit from Debuggable to gain more advanced dumping facilities.

logstream only uses std::ostream for implementation---it does not inherit from one. Most of the features not available in logstream wouldn't be meaningful anyway. In particular the user defined std::ostream insertion operators do not work. logstream is meant for dumping objects' internal representation for debugging purposes, thus the std::ostream inserters would seldomly do the right thing.

logstream does not require any methods or attributes from the the logged objects, and thus the interface is limited to that of std::ostream. However, there is support for more complex operations than what are allowed by bare std::ostream, such as:

The indentation level can be used to clarify complex data structures or program execution. To increase indentation level by one, the program sends the indent manipulator. To decrease the level by one step, the undent manipulator is sent. The logstream takes care of everything else.

The logging output can be sent to a varieyt of logging devices: standard error, file, fifo, pipe, local or internet socket etc. The actual device to use is chosen at runtime via the $LOG environment variable. It relatively easy to add new logging devices if the existing list is not sufficient.

The logstream class has been designed with much care to guarantee the minimum amount of interference with the rest of the program. Here are the most important principles:

Definition at line 240 of file Log.h.


Member Enumeration Documentation

enum lat::logstream::State

Enumerator:
Trace 
Warning 
Error 

Definition at line 243 of file Log.h.

00243 { Trace, Warning, Error };


Constructor & Destructor Documentation

lat::logstream::logstream ( void   ) 

virtual lat::logstream::~logstream ( void   )  [virtual]


Member Function Documentation

static void lat::logstream::checkMode ( logflag mode  )  [static, private]

static logstream* lat::logstream::createConsoleLogDevice ( const char *  args  )  [static, private]

static logstream* lat::logstream::createFileLogDevice ( const char *  args  )  [static, private]

static logstream* lat::logstream::createLocalSocketLogDevice ( const char *  args  )  [static, private]

static logstream* lat::logstream::createPipeLogDevice ( const char *  args  )  [static, private]

static logstream* lat::logstream::createSinkLogDevice ( const char *  args  )  [static, private]

static logstream* lat::logstream::createSocketLogDevice ( bool  local,
bool  tcp,
const char *  args 
) [static, private]

static logstream* lat::logstream::createStderrLogDevice ( const char *  args  )  [static, private]

static logstream* lat::logstream::createTcpSocketLogDevice ( const char *  args  )  [static, private]

static logstream* lat::logstream::createUdpSocketLogDevice ( const char *  args  )  [static, private]

bool lat::logstream::deep ( void   )  const

virtual void lat::logstream::emit ( const char *  string,
int  length 
) [protected, pure virtual]

logstream& lat::logstream::enable ( bool  value = true  ) 

bool lat::logstream::enabled ( void   )  const

static logstream& lat::logstream::error ( logflag mode,
int  level 
) [static]

logstream& lat::logstream::flush ( void   ) 

logstream& lat::logstream::indent ( int  by = 4  ) 

static logstream& lat::logstream::logger ( void   )  [static]

logstream& lat::logstream::mode ( logflag flag,
int  level 
)

logstream& lat::logstream::operator<< ( std::streambuf *  buffer  ) 

logstream& lat::logstream::operator<< ( ios &(*)(ios &)  fn  ) 

logstream& lat::logstream::operator<< ( logstream &(*)(logstream &)  fn  ) 

logstream& lat::logstream::operator<< ( long double  f  ) 

logstream& lat::logstream::operator<< ( float  f  ) 

logstream& lat::logstream::operator<< ( double  f  ) 

logstream& lat::logstream::operator<< ( unsigned short  n  ) 

logstream& lat::logstream::operator<< ( short  n  ) 

logstream& lat::logstream::operator<< ( unsigned long  n  ) 

logstream& lat::logstream::operator<< ( long  n  ) 

logstream& lat::logstream::operator<< ( unsigned int  n  ) 

logstream& lat::logstream::operator<< ( int  n  ) 

logstream& lat::logstream::operator<< ( const void pointer  ) 

logstream& lat::logstream::operator<< ( const std::string &  string  ) 

logstream& lat::logstream::operator<< ( const signed char *  string  ) 

logstream& lat::logstream::operator<< ( const unsigned char *  string  ) 

logstream& lat::logstream::operator<< ( const char *  string  ) 

logstream& lat::logstream::operator<< ( signed char  ch  ) 

logstream& lat::logstream::operator<< ( unsigned char  ch  ) 

logstream& lat::logstream::operator<< ( char  ch  ) 

void lat::logstream::pad ( int  n  )  [private]

logstream& lat::logstream::put ( signed char  ch  ) 

logstream& lat::logstream::put ( unsigned char  ch  ) 

logstream& lat::logstream::put ( char  ch  ) 

void lat::logstream::readjust ( void   )  [private]

logstream& lat::logstream::recurse ( bool  recursion = true  ) 

logstream& lat::logstream::registerMode ( logflag mode  ) 

logstream& lat::logstream::select ( logflag flag  ) 

bool lat::logstream::selected ( void   )  const

logstream& lat::logstream::state ( State  value  ) 

static logstream& lat::logstream::trace ( logflag mode,
int  level 
) [static]

logstream& lat::logstream::undent ( int  by = 4  ) 

logstream& lat::logstream::unselect ( logflag flag  ) 

static logstream& lat::logstream::warning ( logflag mode,
int  level 
) [static]


Friends And Related Function Documentation

friend class buf [friend]

Definition at line 318 of file Log.h.


Member Data Documentation

buf* lat::logstream::m_buf [private]

The logging output buffer.

Definition at line 338 of file Log.h.

bool lat::logstream::m_deep [private]

A flag indicating that objects should dump their contents recursively.

Definition at line 345 of file Log.h.

bool lat::logstream::m_enabled [private]

A flag indicating whether logging is enabled at all.

Definition at line 348 of file Log.h.

int lat::logstream::m_indent [private]

The current indent level.

Definition at line 366 of file Log.h.

int lat::logstream::m_longestModeName [private]

The length of the longest mode name seen so far.

Used to pad out the mode names to same width on output.

Definition at line 373 of file Log.h.

bool lat::logstream::m_longLineHeader [private]

A flag indicating whether the line header should be printed in the long format.

Most applications will prefer the short format; the long format is mostly useful for daemons and multiprocess applications, where it is important to know who produced a message and when.

Definition at line 380 of file Log.h.

const logflag* lat::logstream::m_mode [private]

The current mode flag; defaults to LFall.

Definition at line 355 of file Log.h.

int lat::logstream::m_modeNameLength [private]

The length of the current mode name.

Definition at line 369 of file Log.h.

bool lat::logstream::m_newline [private]

Flag indicating whether the output is at the beginning of the line and the new line should prefixed and indented before actually outputting anything.

Definition at line 363 of file Log.h.

bool lat::logstream::m_selected [private]

A flag indicating whether stream is in selected state, i.e., the current mode has been enabled and the level is chosen.

Definition at line 352 of file Log.h.

State lat::logstream::m_state [private]

The current state (error, warning or trace).

Definition at line 358 of file Log.h.

std::ostream* lat::logstream::m_stream [private]

The real output engine.

Definition at line 341 of file Log.h.

bool lat::logstream::s_deleted [static, private]

A flag to indicate when the logging system has been destroyed.

Used to catch post-destructor LOG() attempts.

Definition at line 396 of file Log.h.

device lat::logstream::s_devices[] [static, private]

List of available logging devices.

Definition at line 399 of file Log.h.

logflag* lat::logstream::s_flags [static, private]

The chain of registered log flags (i.e., used so far).

Definition at line 385 of file Log.h.

bool lat::logstream::s_initialized [static, private]

A flag to indicate when the logging system has been initialized.

Definition at line 392 of file Log.h.

logstream* lat::logstream::s_logger [static, private]

Pointer to the logging device used by the LOG() macros.

Definition at line 388 of file Log.h.


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:48:26 2009 for CMSSW by  doxygen 1.5.4