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);
98 const char * c_str()
const
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 &out,
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);}
506 static Slog::Level levelTranslate(
string name)
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___