43 #ifndef COMMONCPP_APPLOG_H_
44 #define COMMONCPP_APPLOG_H_
46 #ifndef COMMONCPP_SLOG_H_
50 #ifndef COMMONCPP_EXCEPTION_H_
87 HEXdump(
const unsigned char *buffer,
int buff_len,
int max_len = 200);
116 friend std::ostream& operator<< (std::ostream& out,
const HEXdump &hd)
124 #ifdef CCXX_EXCEPTIONS
171 class __EXPORT
AppLog :
protected streambuf,
public ostream
176 void writeLog(
bool endOfLine =
true);
177 static std::map<string, Slog::Level> *assoc;
207 Ident(
const char *str) : _ident(str) {};
212 std::string&
str() {
return _ident;}
217 Ident& operator= (std::string &st) {_ident = st;
return *
this;}
222 Ident& operator= (
const char str[]) {_ident = str;
return *
this;}
227 const char*
c_str() {
return _ident.c_str();}
238 AppLog(
const char* logFileName = NULL,
bool logDirectly =
false ,
bool usePipe =
false);
246 AppLog(
const char* logFileName = NULL,
bool logDirectly =
false);
272 void logFileName(
const char* FileName,
bool logDirectly =
false,
bool usePipe =
false);
280 void logFileName(
const char* FileName,
bool logDirectly =
false);
291 void level(Slog::Level enable);
297 void clogEnable(
bool en =
true);
303 void slogEnable(
bool en =
true);
310 void identLevel(
const char *ident, Slog::Level level);
316 void open(
const char *ident);
323 virtual int overflow(
int c);
334 void emerg(
const char *format, ...);
340 void alert(
const char *format, ...);
346 void critical(
const char *format, ...);
352 void error(
const char *format, ...);
358 void warn(
const char *format, ...);
364 void notice(
const char *format, ...);
370 void info(
const char *format, ...);
376 void debug(
const char *format, ...);
384 AppLog &operator()(
const char *ident, Slog::Level level = Slog::levelError);
402 AppLog &operator()(Slog::Level level);
416 AppLog& operator<< (ostream& (*pfManipulator)(ostream&));
418 friend ostream& operator << (ostream &os,
AppLog & al)
440 {
return operator()(Slog::levelWarning);}
447 {
return operator()(Slog::levelError);}
454 {
return operator()(Slog::levelDebug);}
461 {
return operator()(Slog::levelEmergency);}
468 {
return operator()(Slog::levelAlert);}
475 {
return operator()(Slog::levelCritical);}
482 {
return operator()(Slog::levelNotice);}
489 {
return operator()(Slog::levelInfo);}
508 std::map<string, Slog::Level>::iterator it = assoc->find(name);
509 return (it != assoc->end()) ? it->second : Slog::levelEmergency;
519 __EXPORT
inline AppLog &debug(AppLog& sl)
520 {
return sl.operator()(Slog::levelDebug);}
527 __EXPORT
inline AppLog &warn(AppLog& sl)
528 {
return sl.operator()(Slog::levelWarning);}
535 __EXPORT
inline AppLog &error(AppLog& sl)
536 {
return sl.operator()(Slog::levelError);}
543 __EXPORT
inline AppLog &emerg(AppLog& sl)
544 {
return sl.operator()(Slog::levelEmergency);}
551 __EXPORT
inline AppLog &alert(AppLog& sl)
552 {
return sl.operator()(Slog::levelAlert);}
559 __EXPORT
inline AppLog &critical(AppLog& sl)
560 {
return sl.operator()(Slog::levelCritical);}
567 __EXPORT
inline AppLog ¬ice(AppLog& sl)
568 {
return sl.operator()(Slog::levelNotice);}
575 __EXPORT
inline AppLog &info(AppLog& sl)
576 {
return sl.operator()(Slog::levelInfo);}
581 __EXPORT
extern AppLog alog;
585 #endif //___APPLOG_H___
Applog exception, used for memory problems at the moment.
Produces a dump of a buffer in a hexdump way with its code Ascii translation and relative buffer addr...
AppLog & info(void)
info level
AppLog & alert(void)
alert level
std::string & str()
std::string cast.
virtual ~HEXdump()
HEXdump destructor.
Ident class that represents module name.
Ident(Ident &id)
Copy constructor.
AppLog & critical(void)
critical level
std::string _str
output string
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...
const char * c_str() const
const char* cast provided for conveneince.
std::string str()
string cast provided for conveneince.
Ident(const char *str)
const char* constructor, provided for convenience.
AppLog & warn(void)
warn level
GNU Common C++ exception model base classes.
const char * c_str()
const char* cast provided for conveneince.
AppLog & operator()(Ident &ident)
operator to change ident
System logging facilities abstraction.
Mainline exception handler, this is the root for all Common C++ exceptions and assures the ansi C++ e...
A copy-on-write string class that operates by reference count.
AppLogException(String &what_arg)
Constructor.
AppLog & emerg(void)
emerg level