ost::AppLog(3) | Library Functions Manual | ost::AppLog(3) |
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 Ident
Public Member Functions¶
AppLog (const char *logFileName=NULL, bool logDirectly=false, bool usePipe=false)
Static Public Member Functions¶
static Slog::Level levelTranslate (string name)
Protected Member Functions¶
void writeLog (bool endOfLine=true)
Protected Attributes¶
AppLogPrivate * d
Static Protected Attributes¶
static map< string, Slog::Level > * assoc
Friends¶
ostream & operator<< (ostream &out, AppLog &al)
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::levelEmergency Slog::levelAlert Slog::levelCritical Slog::levelError Slog::levelWarning Slog::levelNotice Slog::levelInfo Slog::levelDebugfrom. Example of usage: alog << mod_name << debug << 'Hello world!' << std::endl;Constructor & Destructor Documentation¶
ost::AppLog::AppLog (const char *logFileName = NULL, boollogDirectly = false, boolusePipe = false)¶
Constructor for a customized logger. Parameters:logFileName 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
virtual ost::AppLog::~AppLog () [virtual]¶
Destructor.Member Function Documentation¶
void ost::AppLog::alert (const char *format, ...)¶
alert level printf style method, provided for convenience. Parameters:format printf format
AppLog& ost::AppLog::alert (void) [inline]¶
alert level Returns:application logger stream
void ost::AppLog::clogEnable (boolen = true)¶
Enables clog output. Parameters:en true to enable clog output.
void ost::AppLog::close (void)¶
if logDirectly is set it closes the file.void ost::AppLog::critical (const char *format, ...)¶
critical level printf style method, provided for convenience. Parameters:format printf format
AppLog& ost::AppLog::critical (void) [inline]¶
critical level Returns:application logger stream
void ost::AppLog::debug (const char *format, ...)¶
debug level printf style method, provided for convenience. Parameters:format printf format
AppLog& ost::AppLog::debug (void) [inline]¶
debug level Returns:application logger stream
void ost::AppLog::emerg (const char *format, ...)¶
emerg level printf style method, provided for convenience. Parameters:format printf format
AppLog& ost::AppLog::emerg (void) [inline]¶
emerg level Returns:application logger stream
void ost::AppLog::error (const char *format, ...)¶
error level printf style method, provided for convenience. Parameters:format printf format
AppLog& ost::AppLog::error (void) [inline]¶
error level Returns:application logger stream
void ost::AppLog::identLevel (const char *ident, Slog::Levellevel)¶
Sets the level for that ident. Parameters:ident ident (module name for instance).
level level
void ost::AppLog::info (const char *format, ...)¶
info level printf style method, provided for convenience. Parameters:format printf format
AppLog& ost::AppLog::info (void) [inline]¶
info level Returns:application logger stream
void ost::AppLog::level ( Slog::Levelenable)¶
Sets the log level. Parameters:enable log level.
static Slog::Level ost::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::levelDebug Parameters:name Slog Level name
Returns:
Slog level value
void ost::AppLog::logFileName (const char *FileName, boollogDirectly = false, boolusePipe = false)¶
Allows to set up ost::alog parameters. Parameters:FileName 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
void ost::AppLog::notice (const char *format, ...)¶
notice level printf style method, provided for convenience. Parameters:format printf format
AppLog& ost::AppLog::notice (void) [inline]¶
notice level Returns:application logger stream
void ost::AppLog::open (const char *ident)¶
Opens the file if not already and sets ident. Parameters:ident module name for instance.
AppLog& ost::AppLog::operator() (const char *ident, Slog::Levellevel = Slog::levelError )¶
operator to change ident and log level Parameters:ident ident (module name for instance)
level new log level
Returns:
application logger stream
AppLog& ost::AppLog::operator() ( Ident &ident) [inline]¶
operator to change ident Parameters:ident 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 Parameters:level 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<< (ostream &(*)(ostream &)pfManipulator)¶
manipulator operator, to use ostream manipulators (i.e. std::endl,...) Parameters:(* pfManipulator)(AppLog &)
Returns:
application logger stream
AppLog& ost::AppLog::operator<< ( Ident &ident) [inline]¶
operator << Parameters:ident module name for instance.
Returns:
application logger stream
References ost::AppLog::Ident::c_str().
virtual int ost::AppLog::overflow (intc) [virtual]¶
stream overflow() overload. Parameters:c character to be managed
Returns:
c
void ost::AppLog::slogEnable (boolen = true)¶
Enables slog output for error level messages. Parameters:en true to enable slog output.
void ost::AppLog::subscribe ()¶
Subscribes the current thread to logger, it reserves thread safe buffer for it.virtual int ost::AppLog::sync () [virtual]¶
stream sync() overloadvoid ost::AppLog::unsubscribe ()¶
Unsubscribes the current thread from logger.void ost::AppLog::warn (const char *format, ...)¶
warn level printf style method, provided for convenience. Parameters:format printf format
AppLog& ost::AppLog::warn (void) [inline]¶
warn level Returns:application logger stream
void ost::AppLog::writeLog (boolendOfLine = true) [protected]¶
Friends And Related Function Documentation¶
ostream& operator<< (ostream &out, AppLog &al) [friend]¶
Member Data Documentation¶
map<string, Slog::Level>* ost::AppLog::assoc [static], [protected]¶
AppLogPrivate* ost::AppLog::d [protected]¶
Author¶
Generated automatically by Doxygen for GNU CommonC++ from the source code.Sun Dec 29 2013 | GNU CommonC++ |