00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef LOGGER_H
00018 #define LOGGER_H
00019
00020 #ifdef HAVE_CONFIG_H
00021 #include "config.h"
00022 #endif
00023
00024 #include <stdio.h>
00025 #include <syslog.h>
00026
00032 class Logger
00033 {
00034 public:
00042
00043
00044
00045
00046
00047
00048
00050 static Logger* Instance();
00051
00053 virtual ~Logger();
00054
00056 int openSyslog(int facility, int priority);
00058 void closeSyslog();
00059
00061 int openFilelog(char* fileName, int priority);
00063 void closeFilelog();
00064
00066 int setSyslogPriority(int priority);
00067
00069 int setFilelogPriority(int priority);
00070
00072 int setIdent(char* ident);
00073
00075
00076
00077 void debug(const char* fmt, ...);
00078 void info(const char* fmt, ...);
00079 void notice(const char* fmt, ...);
00080 void warning(const char* fmt, ...);
00081 void error(const char* fmt, ...);
00082 void crit(const char* fmt, ...);
00083
00084 protected:
00086 Logger();
00087
00088 private:
00089
00090 void log(int priority, const char *string);
00091
00092 char* ident_;
00093
00094 bool isSyslogEnabled_;
00095 bool isFilelogEnabled_;
00096 int syslogPriority_;
00097 int filelogPriority_;
00098
00099 FILE* file_;
00100
00101 static Logger* instance_;
00102 };
00103
00104 #endif