hlswmaster-ng/logging.h

65 lines
1.2 KiB
C
Raw Permalink Normal View History

2006-02-02 16:55:44 +01:00
#ifndef _LOGGING_H_
#define _LOGGING_H_
#include <stdio.h>
// really noisy debugging (pkt-dumps)
#define LOG_DEBUG 5
// normal "debug" (config, recv. packets)
#define LOG_INFO 4
2006-02-05 12:00:47 +01:00
// interesting stuff (unknown packets)
2006-02-02 16:55:44 +01:00
#define LOG_NOTICE 3
// something is not right, but programm is still working (config errors)
#define LOG_WARN 2
// something is *really* bad, but we try to keep up (mem-allocs)
#define LOG_ERROR 1
// we must bailout *now*
#define LOG_CRIT 0
#define LOG_EVERYTIME 0
class LogOutput {
public:
virtual ~LogOutput() {};
virtual void write(const char* buf) {};
};
class LogSystem {
public:
static void init(int prio, LogOutput* lo);
2006-02-05 16:44:38 +01:00
static void init(const char* prio, LogOutput* lo);
2006-02-02 16:55:44 +01:00
static void log(int prio, const char* fmt, ...);
private:
LogSystem();
~LogSystem();
static LogSystem* getInstance();
LogOutput *output;
int priority;
char buffer[8192]; // we need this for (large) packet dumps!
2006-02-02 16:55:44 +01:00
};
class StdErrLog : public LogOutput {
public:
void write(const char* buf);
};
class FileLog : public LogOutput {
public:
FileLog(const char* filename);
~FileLog();
void write(const char* buf);
private:
FILE* logfile;
};
#endif // _LOGGING_H_