Go to the documentation of this file.
43 #ifndef ___APPLOG_H___
44 #define ___APPLOG_H___
57 #ifdef CCXX_NAMESPACES
89 HEXdump(
const unsigned char *buffer,
int buff_len,
int max_len = 200);
126 #ifdef CCXX_EXCEPTIONS
131 class __EXPORT AppLogException :
public ost::Exception
138 AppLogException(
const std::string &what_arg) :
ost::Exception(what_arg) {};
179 static map<string, Slog::Level> *
assoc;
209 Ident(
const char *str) : _ident(str) {};
214 std::string&
str() {
return _ident;}
219 Ident& operator= (std::string &st) {_ident = st;
return *
this;}
224 Ident& operator= (
const char str[]) {_ident = str;
return *
this;}
229 const char*
c_str() {
return _ident.c_str();}
240 AppLog(
const char* logFileName = NULL,
bool logDirectly =
false ,
bool usePipe =
false);
248 AppLog(
const char* logFileName = NULL,
bool logDirectly =
false);
274 void logFileName(
const char* FileName,
bool logDirectly =
false,
bool usePipe =
false);
282 void logFileName(
const char* FileName,
bool logDirectly =
false);
338 void emerg(
const char *format, ...);
344 void alert(
const char *format, ...);
356 void error(
const char *format, ...);
362 void warn(
const char *format, ...);
374 void info(
const char *format, ...);
380 void debug(
const char *format, ...);
445 {
return operator()(Slog::levelWarning);}
452 {
return operator()(Slog::levelError);}
459 {
return operator()(Slog::levelDebug);}
466 {
return operator()(Slog::levelEmergency);}
473 {
return operator()(Slog::levelAlert);}
480 {
return operator()(Slog::levelCritical);}
487 {
return operator()(Slog::levelNotice);}
494 {
return operator()(Slog::levelInfo);}
513 map<string, Slog::Level>::iterator it = assoc->find(name);
515 return (it != assoc->end()) ? it->second : Slog::levelEmergency;
526 {
return sl.operator()(Slog::levelDebug);}
534 {
return sl.operator()(Slog::levelWarning);}
542 {
return sl.operator()(Slog::levelError);}
550 {
return sl.operator()(Slog::levelEmergency);}
558 {
return sl.operator()(Slog::levelAlert);}
566 {
return sl.operator()(Slog::levelCritical);}
574 {
return sl.operator()(Slog::levelNotice);}
582 {
return sl.operator()(Slog::levelInfo);}
589 #ifdef CCXX_NAMESPACES
593 #endif //___APPLOG_H___
AppLog & info(void)
info level
Definition: applog.h:493
AppLog & debug(void)
debug level
Definition: applog.h:458
AppLog(const char *logFileName=NULL, bool logDirectly=false, bool usePipe=false)
Constructor for a customized logger.
void critical(const char *format,...)
critical level printf style method, provided for convenience.
void slogEnable(bool en=true)
Enables slog output for error level messages.
const char * c_str() const
const char* cast provided for conveneince.
Definition: applog.h:100
AppLog & error(void)
error level
Definition: applog.h:451
virtual int overflow(int c)
stream overflow() overload.
void subscribe()
Subscribes the current thread to logger, it reserves thread safe buffer for it.
void open(const char *ident)
Opens the file if not already and sets ident.
System logging facilities abstraction.
static Slog::Level levelTranslate(string name)
Translates level from string to Slog::Level, useful for configuration files for instance.
Definition: applog.h:511
Produces a dump of a buffer in a hexdump way with its code Ascii translation and relative buffer addr...
Definition: applog.h:72
__EXPORT AppLog & debug(AppLog &sl)
Manipulator for debug level.
Definition: applog.h:525
AppLog & alert(void)
alert level
Definition: applog.h:472
Ident(Ident &id)
Copy constructor.
Definition: applog.h:204
__EXPORT AppLog & error(AppLog &sl)
Manipulator for error level.
Definition: applog.h:541
virtual ~AppLog()
Destructor.
AppLog & warn(void)
warn level
Definition: applog.h:444
__EXPORT AppLog & warn(AppLog &sl)
Manipulator for warn level.
Definition: applog.h:533
void close(void)
if logDirectly is set it closes the file.
void debug(const char *format,...)
debug level printf style method, provided for convenience.
Level
Definition: slog.h:123
__EXPORT AppLog & info(AppLog &sl)
Manipulator for info level.
Definition: applog.h:581
void emerg(const char *format,...)
emerg level printf style method, provided for convenience.
AppLog & operator()(Ident &ident)
operator to change ident
Definition: applog.h:396
HEXdump(const unsigned char *buffer, int buff_len, int max_len=200)
HEXdump constructor.
#define __EXPORT
Definition: config.h:979
Ident()
Constructor.
Definition: applog.h:194
AppLog & notice(void)
notice level
Definition: applog.h:486
__EXPORT AppLog & notice(AppLog &sl)
Manipulator for notice level.
Definition: applog.h:573
void level(Slog::Level enable)
Sets the log level.
void error(const char *format,...)
error level printf style method, provided for convenience.
AppLog & operator()(const char *ident, Slog::Level level=Slog::levelError)
operator to change ident and log level
AppLog & emerg(void)
emerg level
Definition: applog.h:465
AppLog & critical(void)
critical level
Definition: applog.h:479
virtual ~HEXdump()
HEXdump destructor.
Definition: applog.h:94
Ident(const char *str)
const char* constructor, provided for convenience.
Definition: applog.h:209
void notice(const char *format,...)
notice level printf style method, provided for convenience.
Ident class that represents module name.
Definition: applog.h:186
AppLog & operator()(Slog::Level level)
operator to change logging level
std::string & str()
std::string cast.
Definition: applog.h:214
AppLogPrivate * d
Definition: applog.h:177
static map< string, Slog::Level > * assoc
Definition: applog.h:179
__EXPORT AppLog & emerg(AppLog &sl)
Manipulator for emerg level.
Definition: applog.h:549
void identLevel(const char *ident, Slog::Level level)
Sets the level for that ident.
void info(const char *format,...)
info level printf style method, provided for convenience.
__EXPORT AppLog & critical(AppLog &sl)
Manipulator for critical level.
Definition: applog.h:565
Application logger is a class that implements a logger that can be used by applications to save log f...
Definition: applog.h:174
void unsubscribe()
Unsubscribes the current thread from logger.
~Ident()
Desctructor.
Definition: applog.h:199
std::string _str
output string
Definition: applog.h:77
const char * c_str()
const char* cast provided for conveneince.
Definition: applog.h:229
void clogEnable(bool en=true)
Enables clog output.
GNU Common C++ exception model base classes.
void logFileName(const char *FileName, bool logDirectly=false, bool usePipe=false)
Allows to set up ost::alog parameters.
void alert(const char *format,...)
alert level printf style method, provided for convenience.
void warn(const char *format,...)
warn level printf style method, provided for convenience.
__EXPORT AppLog & alert(AppLog &sl)
Manipulator for alert level.
Definition: applog.h:557
__EXPORT std::ostream & operator<<(std::ostream &os, const IPV4Address &ia)
virtual int sync()
stream sync() overload
__EXPORT AppLog alog
alog global log stream definition
std::string str()
string cast provided for conveneince.
Definition: applog.h:108
void writeLog(bool endOfLine=true)