Home Libraries Author Links

stm::logger< stdIndent, lineLength, errorConsole, lockingPolicy > Class Template Reference
[LoggerAids: Formatted Logging Aids]

Inheritance diagram for stm::logger< stdIndent, lineLength, errorConsole, lockingPolicy >:

Inheritance graph
[legend]
Collaboration diagram for stm::logger< stdIndent, lineLength, errorConsole, lockingPolicy >:

Collaboration graph
[legend]

List of all members.


Detailed Description

template<word stdIndent = 4, word lineLength = 79, bool errorConsole = false, word lockingPolicy = logger_base::NoLocking>
class stm::logger< stdIndent, lineLength, errorConsole, lockingPolicy >

Class template to manage formatted logging on a std::string based output stream (normally a log file) and optionally on a second std::string based stream (normally a console, by default std::cout, if template parameter errorConsole is false (the default), or else std::cerr).

Since logger is indirectly derived from a std::ostringstream, data insertion into logger objects is easily possible. On construction the base class std::ostingstream object is default constructed and then initialized to use uppercase letters for hexadecimal numbers and to use right adjusted fixed point notation for floating point numbers. If formatted printig to a stream is done, the default value for indentation is given by the template parameter stdIndent and the default line length is given by the template parameter lineLength.

According to the template parameter lockingPolicy either no locking is possible (logger_base::NoLocking) or an unnamed mutex (see Abstract Data Type StmMutex) for logger_base::ProcessLocking or a named mutex (see Abstract Data Type StmNamedMutex) for logger_base::SystemLocking is used by stm::logger::locker to perform locking across all threads of the calling process or across all threads of the system, respectively. The mutex name for system-wide locking has to be supplied to the constructor of stm::logger.

Examples:

filesystest.cpp, smartptrtest.cpp, and sudoku.cpp.

Definition at line 414 of file loggeraids.hpp.


Public Member Functions

 logger (bool enableStream=false, std::ostream &stream=errorConsole?std::cerr:std::cout, const std::string &mutexName=std::string())
 Construct a logger object to print on stream (default the standard console), if enableStream is true (default false).
 logger (bool enableStream, const std::string &mutexName)
 Construct a logger object to print on stream (default the standard console), if enableStream is true.
 logger (std::ostream &stream, const std::string &mutexName)
 Construct a logger object to print on stream.
 logger (std::ostream &stream, bool enableConsole=false, const std::string &mutexName=std::string())
 Construct a logger object to print on stream and on the standard console, if enableConsole is true (default false).
 logger (std::ostream &stream, std::ostream &console, const std::string &mutexName=std::string())
 Construct a logger object to print on stream and on console.
void setConsole ()
 Configure this logger object to print on the standard console.

Constructor & Destructor Documentation

template<word stdIndent = 4, word lineLength = 79, bool errorConsole = false, word lockingPolicy = logger_base::NoLocking>
stm::logger< stdIndent, lineLength, errorConsole, lockingPolicy >::logger ( bool  enableStream = false,
std::ostream &  stream = errorConsole?std::cerr:std::cout,
const std::string &  mutexName = std::string() 
)

Construct a logger object to print on stream (default the standard console), if enableStream is true (default false).

mutexName is the name of the mutex used for system-wide locking, if applicable. If for system-wide locking mutexName is empty, the standard name 'StmLoggerLock' is used.


© Copyright Tom Michaelis 2002-2007

Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).