2001-10-14 14:38:45 +00:00
|
|
|
#ifndef CLOG_H
|
|
|
|
#define CLOG_H
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
class CLog {
|
|
|
|
public:
|
2001-11-19 00:33:36 +00:00
|
|
|
typedef void (*Outputter)(const char*);
|
|
|
|
|
2001-10-14 14:38:45 +00:00
|
|
|
static void print(const char*, ...);
|
|
|
|
static void printt(const char* file, int line, const char*, ...);
|
2001-11-19 00:33:36 +00:00
|
|
|
static void setOutputter(Outputter);
|
2001-10-14 14:38:45 +00:00
|
|
|
|
|
|
|
private:
|
2001-11-19 00:33:36 +00:00
|
|
|
static void output(int priority, char* msg);
|
2001-10-14 14:38:45 +00:00
|
|
|
static char* vsprint(int pad, char*, int len, const char*, va_list);
|
|
|
|
static int nprint(const char*, va_list);
|
2001-11-19 00:33:36 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static Outputter s_outputter;
|
2001-10-14 14:38:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#if defined(NOLOGGING)
|
|
|
|
#define log(_a1)
|
2001-10-14 18:29:43 +00:00
|
|
|
#define logc(_a1, _a2)
|
2001-10-14 14:38:45 +00:00
|
|
|
#define CLOG_TRACE
|
|
|
|
#elif defined(NDEBUG)
|
|
|
|
#define log(_a1) CLog::print _a1
|
2001-10-14 18:29:43 +00:00
|
|
|
#define logc(_a1, _a2) if (_a1) CLog::print _a2
|
2001-10-14 14:38:45 +00:00
|
|
|
#define CLOG_TRACE
|
|
|
|
#else
|
|
|
|
#define log(_a1) CLog::printt _a1
|
2001-10-14 18:29:43 +00:00
|
|
|
#define logc(_a1, _a2) if (_a1) CLog::printt _a2
|
2001-10-14 14:38:45 +00:00
|
|
|
#define CLOG_TRACE __FILE__, __LINE__,
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define CLOG_CRIT CLOG_TRACE "%z\060"
|
|
|
|
#define CLOG_ERR CLOG_TRACE "%z\061"
|
|
|
|
#define CLOG_WARN CLOG_TRACE "%z\062"
|
|
|
|
#define CLOG_NOTE CLOG_TRACE "%z\063"
|
|
|
|
#define CLOG_INFO CLOG_TRACE "%z\064"
|
|
|
|
#define CLOG_DEBUG CLOG_TRACE "%z\065"
|
2002-04-27 18:49:03 +00:00
|
|
|
#define CLOG_DEBUG1 CLOG_TRACE "%z\066"
|
|
|
|
#define CLOG_DEBUG2 CLOG_TRACE "%z\067"
|
2001-10-14 14:38:45 +00:00
|
|
|
|
|
|
|
#endif
|