42 #ifndef COMMONCPP_APPLOG_H_
43 #define COMMONCPP_APPLOG_H_
45 #ifndef COMMONCPP_SLOG_H_
49 #ifndef COMMONCPP_EXCEPTION_H_
86 HEXdump(
const unsigned char *buffer,
int buff_len,
int max_len = 200);
115 friend std::ostream& operator<< (std::ostream& out,
const HEXdump &hd)
123 #ifdef CCXX_EXCEPTIONS
170 class __EXPORT
AppLog :
protected streambuf,
public ostream
175 void writeLog(
bool endOfLine =
true);
176 static std::map<string, Slog::Level> *assoc;
206 Ident(
const char *str) : _ident(str) {};
211 std::string&
str() {
return _ident;}
216 Ident& operator= (std::string &st) {_ident = st;
return *
this;}
221 Ident& operator= (
const char str[]) {_ident = str;
return *
this;}
226 const char*
c_str() {
return _ident.c_str();}
237 AppLog(
const char* logFileName = NULL,
bool logDirectly =
false ,
bool usePipe =
false);
245 AppLog(
const char* logFileName = NULL,
bool logDirectly =
false);
271 void logFileName(
const char* FileName,
bool logDirectly =
false,
bool usePipe =
false);
279 void logFileName(
const char* FileName,
bool logDirectly =
false);
290 void level(Slog::Level enable);
296 void clogEnable(
bool en =
true);
302 void slogEnable(
bool en =
true);
309 void identLevel(
const char *ident, Slog::Level level);
315 void open(
const char *ident);
322 virtual int overflow(
int c);
333 void emerg(
const char *format, ...);
339 void alert(
const char *format, ...);
345 void critical(
const char *format, ...);
351 void error(
const char *format, ...);
357 void warn(
const char *format, ...);
363 void notice(
const char *format, ...);
369 void info(
const char *format, ...);
375 void debug(
const char *format, ...);
383 AppLog &operator()(
const char *ident, Slog::Level level = Slog::levelError);
401 AppLog &operator()(Slog::Level level);
415 AppLog& operator<< (ostream& (*pfManipulator)(ostream&));
417 friend ostream& operator << (ostream &os,
AppLog & al)
439 {
return operator()(Slog::levelWarning);}
446 {
return operator()(Slog::levelError);}
453 {
return operator()(Slog::levelDebug);}
460 {
return operator()(Slog::levelEmergency);}
467 {
return operator()(Slog::levelAlert);}
474 {
return operator()(Slog::levelCritical);}
481 {
return operator()(Slog::levelNotice);}
488 {
return operator()(Slog::levelInfo);}
507 std::map<string, Slog::Level>::iterator it = assoc->find(name);
508 return (it != assoc->end()) ? it->second : Slog::levelEmergency;
518 __EXPORT
inline AppLog &debug(AppLog& sl)
519 {
return sl.operator()(Slog::levelDebug);}
526 __EXPORT
inline AppLog &warn(AppLog& sl)
527 {
return sl.operator()(Slog::levelWarning);}
534 __EXPORT
inline AppLog &error(AppLog& sl)
535 {
return sl.operator()(Slog::levelError);}
542 __EXPORT
inline AppLog &emerg(AppLog& sl)
543 {
return sl.operator()(Slog::levelEmergency);}
550 __EXPORT
inline AppLog &alert(AppLog& sl)
551 {
return sl.operator()(Slog::levelAlert);}
558 __EXPORT
inline AppLog &critical(AppLog& sl)
559 {
return sl.operator()(Slog::levelCritical);}
566 __EXPORT
inline AppLog ¬ice(AppLog& sl)
567 {
return sl.operator()(Slog::levelNotice);}
574 __EXPORT
inline AppLog &info(AppLog& sl)
575 {
return sl.operator()(Slog::levelInfo);}
580 __EXPORT
extern AppLog alog;
584 #endif //___APPLOG_H___
const char * c_str() const
const char* cast provided for conveneince.
Applog exception, used for memory problems at the moment.
std::string _str
output string
AppLog & info(void)
info level
AppLog & alert(void)
alert level
std::string & str()
std::string cast.
AppLogException(const char *what_arg)
Constructor.
Ident class that represents module name.
Ident(Ident &id)
Copy constructor.
AppLog & critical(void)
critical level
Mainline exception handler, this is the root for all Common C++ exceptions and assures the ansi C++ e...
AppLog & notice(void)
notice level
AppLog & error(void)
error level
AppLog & debug(void)
debug level
static Slog::Level levelTranslate(string name)
Translates level from string to Slog::Level, useful for configuration files for instance.
Application logger is a class that implements a logger that can be used by applications to save log f...
Ident(const char *str)
const char* constructor, provided for convenience.
AppLog & warn(void)
warn level
const char * c_str()
const char* cast provided for conveneince.
AppLog & operator()(Ident &ident)
operator to change ident
virtual ~HEXdump()
HEXdump destructor.
System logging facilities abstraction.
std::string str()
string cast provided for conveneince.
AppLog & emerg(void)
emerg level
Produces a dump of a buffer in a hexdump way with its code Ascii translation and relative buffer addr...
GNU Common C++ exception model base classes.