Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

Qmms::Log::PatternLayout Class Reference

A layout formatted according to a pattern of tokens. More...

#include <log.hh>

Inheritance diagram for Qmms::Log::PatternLayout::

Qmms::Log::Layout List of all members.

Public Methods

 PatternLayout ()
 Default constuctor uses default values for pattern and date/time format. More...

 PatternLayout (const QString &ptn)
 Constructor. More...

 ~PatternLayout ()
 Destructor does nothing. More...

QString formatEvent (const LoggingEvent *evnt)
 Takes a LoggingEvent and formats its members according to the pattern of tokens/text. More...

bool changePattern (const QString ptn)
 Changes the pattern to the one provided. More...

QString getPattern () const
 Accessor method. More...

QString getDate (const LoggingEvent *evnt) const
 Given a LoggingEvent, gets its date/time and formats according to the date/time format. More...

bool changeDateTimeFormat (const QString format)
 Changes the date/time format to the given one. More...


Private Methods

bool isValidPattern (const QString ptn)
 Checks whether the given string qualifies as a valid pattern. More...


Private Attributes

QString pattern
 The pattern of tokens and text to be used. More...

QString dtFormat
 The date/time format. More...


Static Private Attributes

const QString DEFAULT_PATTERN
 Default patturn is: /d /c /p. More...

const QString DEFAULT_DATETIME_FORMAT
 Default date/time format is ddd dd MMM hh:mm:ss yyyy. More...


Detailed Description

A layout formatted according to a pattern of tokens.

The tokens are preceded by a slash / and can be any of the following:

   /c - name of category
   /C - fully-qualified name of class within which logging occured
   /d - date/time of logging event
   /m - message to log
   /l - level of logging event
   /n - start a new line
 
One can include other text anywhere in the pattern. E.g., to print the following:
         (Tue 15 Jan 17:38:50 2002) cat-WARN: This is a warn 
 
use the pattern
                   (/d) /c-/l: /m /n
 


Constructor & Destructor Documentation

Qmms::Log::PatternLayout::PatternLayout  
 

Default constuctor uses default values for pattern and date/time format.

Qmms::Log::PatternLayout::PatternLayout const QString   ptn
 

Constructor.

Parameters:
ptn  ref to the pattern of tokens and text to use for logging

Qmms::Log::PatternLayout::~PatternLayout  
 

Destructor does nothing.


Member Function Documentation

bool Qmms::Log::PatternLayout::changeDateTimeFormat const QString    format
 

Changes the date/time format to the given one.

No attempt is made to check format for validity; make sure your formats are correct. See docs for QDateTime::toString() for description of formats.

Parameters:
format  the new date/time format
Returns:
true if successful, false otherwise

bool Qmms::Log::PatternLayout::changePattern const QString    ptn
 

Changes the pattern to the one provided.

Checks the new pattern for validity before doing anything else.

Parameters:
ptn  the new pattern
Returns:
true if pattern was valid, false otherwise

QString Qmms::Log::PatternLayout::formatEvent const LoggingEvent   evnt [virtual]
 

Takes a LoggingEvent and formats its members according to the pattern of tokens/text.

Parameters:
evnt  pointer to the LoggingEvent to format
Returns:
the LoggingEvent formatted as a QString

Reimplemented from Qmms::Log::Layout.

QString Qmms::Log::PatternLayout::getDate const LoggingEvent   evnt const
 

Given a LoggingEvent, gets its date/time and formats according to the date/time format.

Parameters:
evnt  the LoggingEvent whose date we want
Returns:
the formatted date/time

QString Qmms::Log::PatternLayout::getPattern   const
 

Accessor method.

Returns:
the current pattern

bool Qmms::Log::PatternLayout::isValidPattern const QString    ptn [private]
 

Checks whether the given string qualifies as a valid pattern.

Parameters:
ptn  the pattern to check
Returns:
true if valid, false otherwise


Member Data Documentation

const QString Qmms::Log::PatternLayout::DEFAULT_DATETIME_FORMAT [static, private]
 

Default date/time format is ddd dd MMM hh:mm:ss yyyy.

const QString Qmms::Log::PatternLayout::DEFAULT_PATTERN [static, private]
 

Default patturn is: /d /c /p.

QString Qmms::Log::PatternLayout::dtFormat [private]
 

The date/time format.

QString Qmms::Log::PatternLayout::pattern [private]
 

The pattern of tokens and text to be used.


The documentation for this class was generated from the following file:
Generated on Fri Jan 3 15:04:05 2003 for QmmsLog by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001