Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

nglLog Class Reference

#include <nglLog.h>

List of all members.


Detailed Description

Logging facilities.

The nglLog class is a simple facility to manage event logging or simple debugging. A nglLog object can have :

Domains let you easily classify the events in your application : if you follow some simple guidelines, you will be able to tune very precisely which messages you want to log and their given verbose level.

NGL programs have an application log which is always created at startup and used internally by NGL to report errors and other useful informations. Have a look at nglApplication::GetLog() and nglApplication::ParseDefaultArgs() to see how this facility can help you.


Public Types

typedef uint StampFlags

Public Member Functions

Life cycle
 nglLog (bool UseConsole=true)
virtual ~nglLog ()
Formatting flags
void SetFlags (StampFlags Flags)
StampFlags GetFlags ()
Output selection
void UseConsole (bool Use)
bool AddOutput (nglOStream *pStream)
bool DelOutput (nglOStream *pStream)
Domain management
uint GetLevel (const nglChar *pDomain)
void SetLevel (const nglChar *pDomain, uint Level)
Output methods
void Log (const nglChar *pDomain, uint Level, const nglChar *pText,...)
void Logv (const nglChar *pDomain, uint Level, const nglChar *pText, va_list Args)
void Dump (uint Level=0) const

Static Public Attributes

static const StampFlags NoStamp
static const StampFlags TimeStamp
static const StampFlags DateStamp
static const StampFlags DomainStamp


Member Typedef Documentation

typedef uint nglLog::StampFlags
 


Constructor & Destructor Documentation

nglLog::nglLog bool  UseConsole = true  ) 
 

Parameters:
UseConsole output events to the console
You can add outputs later. Set UseConsole explicitly to false if you want to use only alternate methods (file, network). See the AddOutput() and UseConsole() methods.

virtual nglLog::~nglLog  )  [virtual]
 

Flush all pending events and clos all current outputs.


Member Function Documentation

bool nglLog::AddOutput nglOStream pStream  ) 
 

Add an output stream

Parameters:
pStream new output stream
Returns:
true if the stream was succesfully added

bool nglLog::DelOutput nglOStream pStream  ) 
 

Remove an output stream

Parameters:
pStream output stream to remove
Returns:
true if the domain was found and succesfuly removed

void nglLog::Dump uint  Level = 0  )  const
 

Dumps domain usage statistics using Level verbosity.

StampFlags nglLog::GetFlags  ) 
 

Get current output flags.

uint nglLog::GetLevel const nglChar pDomain  ) 
 

Get the verbose level from a domain name

Parameters:
pDomain domain name
Returns:
verbose level. This is set to zero if the domain is unknown

void nglLog::Log const nglChar pDomain,
uint  Level,
const nglChar pText,
  ...
 

Log an event

Parameters:
pDomain domain name
Level verbose level
pText format string
... arguments
The domain name is case sensitive, use them consistently in your programs. The "" empty string is a valid domain; however note that the ':' separator will still be displayed if you activated domain stamping, in order to keep log parsing consistent.

The message Level is compared against the domain's current verbose level : if the first is lower or equal to the latter, the event is logged. As a consequence, level 0 events are unmaskable, since a domain verbose level is at least 0.

Trailing newlines are automaticaly removed, and multiples lines message have each of their lines properly stamped.

void nglLog::Logv const nglChar pDomain,
uint  Level,
const nglChar pText,
va_list  Args
 

Log an event

Parameters:
pDomain domain name
Level verbose level
pText format string
Args arguments
Vararg variant of the Log() method.

void nglLog::SetFlags StampFlags  Flags  ) 
 

Set output flags.

void nglLog::SetLevel const nglChar pDomain,
uint  Level
 

Set the verbose level of a domain

Parameters:
pDomain domain name
Level new verbose level
If pDomain is set to "all", Level will be applied to all known domains and used as the default verbose level for yet unknown domains.

void nglLog::UseConsole bool  Use  ) 
 

Send log output to the application's console.


Member Data Documentation

const StampFlags nglLog::DateStamp [static]
 

Add a date stamp (YY/MM/DD format).

const StampFlags nglLog::DomainStamp [static]
 

Add a domain stamp (domain:).

const StampFlags nglLog::NoStamp [static]
 

Do not stamp log lines (raw output).

const StampFlags nglLog::TimeStamp [static]
 

Add a time stamp (HH:MM:SS format).


Generated on Thu Feb 3 22:26:10 2005 for NGL by  doxygen 1.4.1