-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogs.h
More file actions
89 lines (75 loc) · 1.29 KB
/
Logs.h
File metadata and controls
89 lines (75 loc) · 1.29 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* logs.h
*
* Created on: 2014-9-2
* Author: imdb
*/
#ifndef LOGS_H_
#define LOGS_H_
#include <stdio.h>
#include <stdarg.h>
#include <sys/time.h>
#include "CMysqlUtil.h"
#define INFO
#define DEBUG
//namespace Logs
//{
#define log(format,...) LOG(format,...)
#define elog(format,...) ELOG(format,...)
//}
#define LOGINFO(type) \
struct timeval tv; \
struct tm *tm; \
gettimeofday(&tv, NULL); \
tm = localtime(&tv.tv_sec); \
printf("[%d-%d-%d %d:%d:%d.%ld] ", \
tm->tm_year+1900, tm->tm_mon, tm->tm_mday, \
tm->tm_hour, tm->tm_min, tm->tm_sec, \
tv.tv_usec); \
printf(type); \
printf(" %s:%d ", \
__FILE__, __LINE__);
#ifdef INFO
#define LOG(format, ...) \
{ \
LOGINFO("INFO ") \
printf(format, ##__VA_ARGS__); \
printf("\n"); \
}
#define LOGS(s) \
{ \
LOGINFO("INFO ") \
cout<<s<<endl; \
}
#else
#define LOG(format, ...)
#define LOGS(format, ...)
#endif
#ifdef DEBUG
#define DLOG(format, ...) \
{ \
LOGINFO("DEBUG") \
printf(format, ##__VA_ARGS__); \
printf("\n"); \
}
#define DLOGS(s) \
{ \
LOGINFO("DEBUG") \
cout<<s<<endl; \
}
#else
#define DLOG(format, ...)
#define DLOGS(format, ...)
#endif
#define ELOG(format, ...) \
{ \
LOGINFO("ERROR") \
printf(format, ##__VA_ARGS__); \
printf("\n"); \
}
#define ELOGS(s) \
{ \
LOGINFO("ERROR") \
cout<<s<<endl; \
}
#endif /* LOGS_H_ */