42#ifndef COMMONCPP_APPLOG_H_
43#define COMMONCPP_APPLOG_H_
45#ifndef COMMONCPP_CONFIG_H_
46#include <commoncpp/config.h>
49#ifndef COMMONCPP_SLOG_H_
53#ifndef COMMONCPP_EXCEPTION_H_
91 HEXdump(
const uint8_t *buffer,
int buff_len,
int max_len = 200);
118 friend std::ostream& operator<< (std::ostream& out,
const HEXdump &hd)
126#ifdef CCXX_EXCEPTIONS
143class __LOCAL AppLogPrivate;
173class __EXPORT
AppLog :
protected streambuf,
public ostream
178 void writeLog(
bool endOfLine =
true);
179 static std::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()
const {
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);
336 void emerg(
const char *format, ...);
342 void alert(
const char *format, ...);
354 void error(
const char *format, ...);
360 void warn(
const char *format, ...);
372 void info(
const char *format, ...);
378 void debug(
const char *format, ...);
417 AppLog& operator<< (ostream& (*pfManipulator)(ostream&));
419 friend ostream& operator << (ostream &os,
AppLog & al)
441 {
return operator()(Slog::levelWarning);}
448 {
return operator()(Slog::levelError);}
455 {
return operator()(Slog::levelDebug);}
462 {
return operator()(Slog::levelEmergency);}
469 {
return operator()(Slog::levelAlert);}
476 {
return operator()(Slog::levelCritical);}
483 {
return operator()(Slog::levelNotice);}
490 {
return operator()(Slog::levelInfo);}
509 std::map<string, Slog::Level>::iterator it = assoc->find(name);
510 return (it != assoc->end()) ? it->second : Slog::levelEmergency;
521{
return sl.operator()(Slog::levelDebug);}
529{
return sl.operator()(Slog::levelWarning);}
537{
return sl.operator()(Slog::levelError);}
545{
return sl.operator()(Slog::levelEmergency);}
553{
return sl.operator()(Slog::levelAlert);}
561{
return sl.operator()(Slog::levelCritical);}
569{
return sl.operator()(Slog::levelNotice);}
577{
return sl.operator()(Slog::levelInfo);}
582__EXPORT
extern AppLog alog;
GNU Common C++ exception model base classes.
System logging facilities abstraction.
AppLog & notice(AppLog &sl)
Manipulator for notice level.
AppLog & alert(AppLog &sl)
Manipulator for alert level.
AppLog & debug(AppLog &sl)
Manipulator for debug level.
AppLog & error(AppLog &sl)
Manipulator for error level.
AppLog & critical(AppLog &sl)
Manipulator for critical level.
AppLog & emerg(AppLog &sl)
Manipulator for emerg level.
AppLog & warn(AppLog &sl)
Manipulator for warn level.
AppLog & info(AppLog &sl)
Manipulator for info level.
Produces a dump of a buffer in a hexdump way with its code Ascii translation and relative buffer addr...
std::string str()
string cast provided for conveneince.
HEXdump(const uint8_t *buffer, int buff_len, int max_len=200)
HEXdump constructor.
std::string _str
output string
virtual ~HEXdump()
HEXdump destructor.
const char * c_str() const
const char* cast provided for conveneince.
Applog exception, used for memory problems at the moment.
AppLogException(const char *what_arg)
Constructor.
Application logger is a class that implements a logger that can be used by applications to save log f...
AppLog & emerg(void)
emerg level
void info(const char *format,...)
info level printf style method, provided for convenience.
AppLog & critical(void)
critical level
void slogEnable(bool en=true)
Enables slog output for error level messages.
AppLog & notice(void)
notice level
void debug(const char *format,...)
debug level printf style method, provided for convenience.
void notice(const char *format,...)
notice level printf style method, provided for convenience.
AppLog & error(void)
error level
static Slog::Level levelTranslate(string name)
Translates level from string to Slog::Level, useful for configuration files for instance.
AppLog & operator()(const char *ident, Slog::Level level=Slog::levelError)
operator to change ident and log level
void subscribe()
Subscribes the current thread to logger, it reserves thread safe buffer for it.
void alert(const char *format,...)
alert level printf style method, provided for convenience.
void critical(const char *format,...)
critical level printf style method, provided for convenience.
AppLog & operator()(const Ident &ident)
operator to change ident
AppLog & alert(void)
alert level
virtual int sync()
stream sync() overload
AppLog(const char *logFileName=NULL, bool logDirectly=false, bool usePipe=false)
Constructor for a customized logger.
virtual ~AppLog()
Destructor.
void identLevel(const char *ident, Slog::Level level)
Sets the level for that ident.
AppLog & operator()(Slog::Level level)
operator to change logging level
AppLog & info(void)
info level
virtual int overflow(int c)
stream overflow() overload.
void clogEnable(bool en=true)
Enables clog output.
void error(const char *format,...)
error level printf style method, provided for convenience.
void open(const char *ident)
Opens the file if not already and sets ident.
AppLog & debug(void)
debug level
void emerg(const char *format,...)
emerg level printf style method, provided for convenience.
void level(Slog::Level enable)
Sets the log level.
void logFileName(const char *FileName, bool logDirectly=false, bool usePipe=false)
Allows to set up ost::alog parameters.
void unsubscribe()
Unsubscribes the current thread from logger.
void close(void)
if logDirectly is set it closes the file.
AppLog & warn(void)
warn level
void warn(const char *format,...)
warn level printf style method, provided for convenience.
Ident class that represents module name.
const char * c_str() const
const char* cast provided for conveneince.
std::string & str()
std::string cast.
Ident(Ident &id)
Copy constructor.
Ident(const char *str)
const char* constructor, provided for convenience.
Mainline exception handler, this is the root for all Common C++ exceptions and assures the ansi C++ e...