Home Libraries Author Links

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

Inheritance diagram for stm::basic_logger< StringT, stdIndent, lineLength, lockingPolicy >:

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

Collaboration graph
[legend]

List of all members.


Detailed Description

template<class StringT, word stdIndent = 4, word lineLength = 79, word lockingPolicy = logger_base::NoLocking>
class stm::basic_logger< StringT, stdIndent, lineLength, lockingPolicy >

Class template to manage formatted logging on an output stream (normally a log file) and optionally on a second stream (normally a console) and on the system log (see stm::syslog()).

The template parameter StringT shall be a std::basic_string (23.3) specialization. Since basic_logger is publicly derived from a StringT based std::basic_ostringstream (27.7.3), data insertion into basic_logger objects is easily possible. On construction the base class std::basic_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::basic_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::basic_logger.

Definition at line 165 of file loggeraids.hpp.


Public Types

enum  {
  StdIndent = stdIndent,
  LineLength = lineLength,
  LockingPolicy = lockingPolicy
}
enum  FmtFlags {
  NoFlag = impl::NoFlag,
  Indent = impl::Indent,
  NoPara = impl::NoPara,
  KeepWs = impl::KeepWs,
  AutoInd = impl::AutoInd,
  ColonInd = impl::ColonInd,
  ColonTable = impl::ColonTable,
  RiJust = impl::RiJust,
  RawPath = impl::RawPath,
  Single = impl::Single
}
 Format information flags. More...
typedef basic_logger< StringT,
stdIndent, lineLength,
lockingPolicy > 
logger_type
 This basic_logger type.
typedef StringT string_type
 String type.
typedef std::basic_ostream
< typename
string_type::value_type,
typename
string_type::traits_type > 
ostream_type
 Output stream type.
typedef impl::char_type char_type
 Character type.

Public Member Functions

 basic_logger (const std::string &mutexName=std::string())
 Default constructor for a basic_logger object not to print.
 basic_logger (const logger_type &other)
 Copy constructor.
 basic_logger (ostream_type &stream, const std::string &mutexName=std::string())
 Construct a basic_logger object to print on stream.
 basic_logger (ostream_type &stream, ostream_type &console, const std::string &mutexName=std::string())
 Construct a basic_logger object to print on stream and on console.
 ~basic_logger ()
 Destroy a basic_logger object.
bool hasStream () const
 Return true, if this basic_logger object has a stream, else false.
void setStream (ostream_type &stream)
 Configure this basic_logger object to print on stream.
void unsetStream ()
 Configure this basic_logger object to print on no stream.
bool hasConsole () const
 Return true, if this basic_logger object has a console, else false.
void setConsole (ostream_type &console)
 Configure this basic_logger object to print on console.
void unsetConsole ()
 Configure this basic_logger object to print on no console.
int adjustChild ()
 Adjust this basic_logger object after a call to fork().
int operator() (Fmt streamFmt=Fmt(), Fmt consoleFmt=Fmt())
 Print the contents of the string stream base of this basic_logger to the streams configured and then clear it.
int underline (int n, char_type ch=char_type('='), dword nl=1)
 Print character ch (default '=') n times to the streams configured, followed by nl times (default 1) the newline character.
int paragraph (dword nl=1)
 Print on each configured stream as much newlines that at least nl empty lines are present after the last recently printed non empty line.

Static Public Member Functions

static string_type mkPath (const string_type &str)
 Return a copy of str, if str does not contain white space, else str quoted by '"' characters.

Classes

struct  Fmt
 Format information for output streams. More...
struct  locker
 Scoped locking for output streams. More...

© Copyright Tom Michaelis 2002-2007

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