ost::AppLog - Application logger is a class that implements a logger that can be used by applications to
Contents
Constructor & Destructor Documentation
ost::AppLog::AppLog(constchar*logFileName=NULL,boollogDirectly=false,boolusePipe=false)
Constructor for a customized logger.
ParameterslogFileName log file name.
logDirectly true to write directly to file, false to use a spooler like logger.
usePipe true to use pipe instead of file, false otherwise
virtualost::AppLog::~AppLog()[virtual]
Destructor.
Detailed Description
Application logger is a class that implements a logger that can be used by applications to save log file
somewhere on the system.
It uses ost::slog to write to syslog and std::clog to write to standard output.
It provides either a stream oriented logger or a old printf style one.
It can be used to log directly on a file or in a spooler like way. Latter uses a ost::ThreadQueue to
implement a thread safe access to logger.
It provides a global stream variable called ost::alog.
It provides an AppLog::Ident class that represents a module name for instance that can be used to tag
logs. Logging levels are the same defined into ost::Slog: Slog::levelEmergencySlog::levelAlertSlog::levelCriticalSlog::levelErrorSlog::levelWarningSlog::levelNoticeSlog::levelInfo
Slog::levelDebugfrom.
Example of usage: alog << mod_name << debug << 'Hello world!' << std::endl;
Member Data Documentation
map<string,Slog::Level>*ost::AppLog::assoc[static],[protected]AppLogPrivate*ost::AppLog::d[protected]
Member Function Documentation
voidost::AppLog::alert(constchar*format,...)
alert level printf style method, provided for convenience.
Parametersformat printf format
AppLog&ost::AppLog::alert(void)[inline]
alert level
Returns
application logger stream
voidost::AppLog::clogEnable(boolen=true)
Enables clog output.
Parametersen true to enable clog output.
voidost::AppLog::close(void)
if logDirectly is set it closes the file.
voidost::AppLog::critical(constchar*format,...)
critical level printf style method, provided for convenience.
Parametersformat printf format
AppLog&ost::AppLog::critical(void)[inline]
critical level
Returns
application logger stream
voidost::AppLog::debug(constchar*format,...)
debug level printf style method, provided for convenience.
Parametersformat printf format
AppLog&ost::AppLog::debug(void)[inline]
debug level
Returns
application logger stream
voidost::AppLog::emerg(constchar*format,...)
emerg level printf style method, provided for convenience.
Parametersformat printf format
AppLog&ost::AppLog::emerg(void)[inline]
emerg level
Returns
application logger stream
voidost::AppLog::error(constchar*format,...)
error level printf style method, provided for convenience.
Parametersformat printf format
AppLog&ost::AppLog::error(void)[inline]
error level
Returns
application logger stream
voidost::AppLog::identLevel(constchar*ident,Slog::Levellevel)
Sets the level for that ident.
Parametersident ident (module name for instance).
level level
voidost::AppLog::info(constchar*format,...)
info level printf style method, provided for convenience.
Parametersformat printf format
AppLog&ost::AppLog::info(void)[inline]
info level
Returns
application logger stream
voidost::AppLog::level(Slog::Levelenable)
Sets the log level.
Parametersenable log level.
staticSlog::Levelost::AppLog::levelTranslate(stringname)[inline],[static]
Translates level from string to Slog::Level, useful for configuration files for instance. Valid level
names are: 'emerg' for Slog::levelEmergency 'alert' for Slog::levelAlert 'critical' for
Slog::levelCritical 'error' for Slog::levelError 'warn' for Slog::levelWarning 'notice' for
Slog::levelNotice 'info' for Slog::levelInfo 'debug' for Slog::levelDebugParametersnameSlog Level name
ReturnsSlog level value
voidost::AppLog::logFileName(constchar*FileName,boollogDirectly=false,boolusePipe=false)
Allows to set up ost::alog parameters.
ParametersFileName log file name.
logDirectly true to write directly to file, false to use a spooler like logger.
usePipe true to use pipe instead of file, false otherwise
voidost::AppLog::notice(constchar*format,...)
notice level printf style method, provided for convenience.
Parametersformat printf format
AppLog&ost::AppLog::notice(void)[inline]
notice level
Returns
application logger stream
voidost::AppLog::open(constchar*ident)
Opens the file if not already and sets ident.
Parametersident module name for instance.
AppLog&ost::AppLog::operator()(constchar*ident,Slog::Levellevel=Slog::levelError)
operator to change ident and log level
Parametersident ident (module name for instance)
level new log level
Returns
application logger stream
AppLog&ost::AppLog::operator()(Ident&ident)[inline]
operator to change ident
Parametersident ident (module name for instance)
Returns
application logger stream
References ost::AppLog::Ident::c_str().
AppLog&ost::AppLog::operator()(Slog::Levellevel)
operator to change logging level
Parameterslevel new log level
Returns
application logger stream
AppLog&ost::AppLog::operator<<(AppLog&(*)(AppLog&)pfManipulator)
manipulator operator, to change print levels.
Parameters(* pfManipulator)(AppLog &)
Returns
application logger stream
AppLog&ost::AppLog::operator<<(Ident&ident)[inline]
operator <<
Parametersident module name for instance.
Returns
application logger stream
References ost::AppLog::Ident::c_str().
AppLog&ost::AppLog::operator<<(ostream&(*)(ostream&)pfManipulator)
manipulator operator, to use ostream manipulators (i.e. std::endl,...)
Parameters(* pfManipulator)(AppLog &)
Returns
application logger stream
virtualintost::AppLog::overflow(intc)[virtual]
stream overflow() overload.
Parametersc character to be managed
Returns
c
voidost::AppLog::slogEnable(boolen=true)
Enables slog output for error level messages.
Parametersen true to enable slog output.
voidost::AppLog::subscribe()
Subscribes the current thread to logger, it reserves thread safe buffer for it.
virtualintost::AppLog::sync()[virtual]
stream sync() overload
voidost::AppLog::unsubscribe()
Unsubscribes the current thread from logger.
voidost::AppLog::warn(constchar*format,...)
warn level printf style method, provided for convenience.
Parametersformat printf format
AppLog&ost::AppLog::warn(void)[inline]
warn level
Returns
application logger stream
voidost::AppLog::writeLog(boolendOfLine=true)[protected]Name
ost::AppLog - Application logger is a class that implements a logger that can be used by applications to
save log file somewhere on the system.
Synopsis
#include <applog.h>
Inherits streambuf, and ostream.
Classes
class IdentIdent class that represents module name.
PublicMemberFunctionsAppLog (const char *logFileName=NULL, bool logDirectly=false, bool usePipe=false)
Constructor for a customized logger.
virtual ~AppLog ()
Destructor.
void subscribe ()
Subscribes the current thread to logger, it reserves thread safe buffer for it.
void unsubscribe ()
Unsubscribes the current thread from logger.
void logFileName (const char *FileName, bool logDirectly=false, bool usePipe=false)
Allows to set up ost::alog parameters.
void close (void)
if logDirectly is set it closes the file.
void level (Slog::Level enable)
Sets the log level.
void clogEnable (bool en=true)
Enables clog output.
void slogEnable (bool en=true)
Enables slog output for error level messages.
void identLevel (const char *ident, Slog::Levellevel)
Sets the level for that ident.
void open (const char *ident)
Opens the file if not already and sets ident.
virtual int overflow (int c)
stream overflow() overload.
virtual int sync ()
stream sync() overload
void emerg (const char *format,...)
emerg level printf style method, provided for convenience.
void alert (const char *format,...)
alert level printf style method, provided for convenience.
void critical (const char *format,...)
critical level printf style method, provided for convenience.
void error (const char *format,...)
error level printf style method, provided for convenience.
void warn (const char *format,...)
warn level printf style method, provided for convenience.
void notice (const char *format,...)
notice level printf style method, provided for convenience.
void info (const char *format,...)
info level printf style method, provided for convenience.
void debug (const char *format,...)
debug level printf style method, provided for convenience.
AppLog & operator() (const char *ident, Slog::Levellevel=Slog::levelError)
operator to change ident and log level
AppLog & operator() (Ident &ident)
operator to change ident
AppLog & operator() (Slog::Levellevel)
operator to change logging level
AppLog & operator<< (AppLog &(*pfManipulator)(AppLog &))
manipulator operator, to change print levels.
AppLog & operator<< (ostream &(*pfManipulator)(ostream &))
manipulator operator, to use ostream manipulators (i.e.
AppLog & operator<< (Ident &ident)
operator <<
AppLog & warn (void)
warn level
AppLog & error (void)
error level
AppLog & debug (void)
debug level
AppLog & emerg (void)
emerg level
AppLog & alert (void)
alert level
AppLog & critical (void)
critical level
AppLog & notice (void)
notice level
AppLog & info (void)
info level
StaticPublicMemberFunctions
static Slog::LevellevelTranslate (string name)
Translates level from string to Slog::Level, useful for configuration files for instance.
ProtectedMemberFunctions
void writeLog (bool endOfLine=true)
ProtectedAttributes
AppLogPrivate * dStaticProtectedAttributes
static map< string, Slog::Level > * assocFriends
ostream & operator<< (ostream &out, AppLog &al)
