-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdebug.hpp
63 lines (50 loc) · 1.44 KB
/
debug.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef LOG_NOT_DEBUG_H
#define LOG_NOT_DEBUG_H
#include "lognot.hpp"
//----------------------------------------------------------------------------------------
class LNLog {
public:
typedef enum LNLogType {
DLOG_INFO=1,
DLOG_WARNING,
DLOG_ERROR,
DLOG_FATAL,
DLOG_DEBUG
} Type;
typedef enum LNLogFacility {
STDOUT_LOG = 1,
FILE_LOG,
SYSTEM_LOG
} LogFacility;
static int log(LNLogType type, const char *message);
static int logInfo(const char *format, ...);
static int logWarning(const char *format, ...);
static int logDebug(const char *format, ...);
static int logError(const char *format, ...);
static int logFatal(const char *format, ...);
static bool setupLogFacility(LogFacility facility, FILE* fd=0);
static LNLog::LogFacility getLogFacility();
static void setDebugMode(bool debug);
static void closeLog();
protected:
static void _close_log();
public:
static FILE *log_file_descriptor;
static bool log_to_stdout, debug_is_on;
static LogFacility log_facility;
static unsigned int prev_log_crc;
static unsigned int prev_log_count;
static time_t prev_log_time;
};
//----------------------------------------------------------------------------------------
class LNException : public std::exception {
public:
LNException(const char *desc) throw();
virtual ~LNException() throw() { ; }
virtual const char *what() const throw() {
return m_desc.c_str();
}
private:
std::string m_desc;
};
#endif // LOG_NOT_DEBUG_H