Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields  

sword::Log Class Reference

Centralized log emitter. More...


Public Types

enum  Level {
  Debug = 0, Info, Warning, Error,
  Fatal, NOTUSED
}
 The various possible Log levels. More...


Static Public Methods

const char * levelStr (Level level)
 Get a string description for a log level.

std::string format (const Entry &entry, const std::string &timestampFormat)
 Get a formatted version of this log message.

std::string printf (const char *format,...)
 Format some data using a printf-style string.

void flush ()
LogStream & log (Level level)
 Singleton access to the logging stream.


Static Public Attributes

sword::Log::Endl endl


Detailed Description

Centralized log emitter.

This class is the central point for logging information from any program. The actual place(s) where the logs will appear depends the the various LogMedia instances registered in the LogMediaManager.

The Log features are accessed using static methods (as if it was a global instance), but are really thread-local, so using the logger is fully thread-safe.

A log "line" can be built using stream operators (as you would do with std::cout for instance), and must always end with Log::endl (otherwise your log line will be stuck or sent not when you expect to).

Example:

  Log::log(Log::Info) << "My log information line x=" << x << Log::endl;
  


Member Enumeration Documentation

enum sword::Log::Level
 

The various possible Log levels.


Member Function Documentation

std::string sword::Log::format const Entry &    entry,
const std::string &    timestampFormat
[static]
 

Get a formatted version of this log message.

This method "formats" the log message: it appends the current timestamp, the log level and the actual message into one nice log line.

const char* sword::Log::levelStr Level    level [static]
 

Get a string description for a log level.

LogStream& sword::Log::log Level    level [static]
 

Singleton access to the logging stream.

std::string sword::Log::printf const char *    format,
...   
[static]
 

Format some data using a printf-style string.


Generated on Tue Dec 23 20:08:57 2003 for SWORD by doxygen1.3-rc2