This repository has been archived by the owner on Jul 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
/
wbLogger.h
100 lines (81 loc) · 3.17 KB
/
wbLogger.h
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
90
91
92
93
94
95
96
97
98
99
100
#ifndef __WB_LOGGER_H__
#define __WB_LOGGER_H__
#include <stdint.h>
typedef enum en_wbLogLevel_t {
wbLogLevel_unknown = -1,
wbLogLevel_OFF = 0,
wbLogLevel_FATAL,
wbLogLevel_ERROR,
wbLogLevel_WARN,
wbLogLevel_INFO,
wbLogLevel_DEBUG,
wbLogLevel_TRACE
} wbLogLevel_t;
struct st_wbLogEntry_t {
char * id;
char * session_id;
int line;
int mpiRank;
char *msg;
uint64_t time;
const char *fun;
const char *file;
wbLogLevel_t level;
wbLogEntry_t next;
};
struct st_wbLogger_t {
char * id;
char * session_id;
int length;
wbLogEntry_t head;
wbLogLevel_t level;
};
#define wbLogEntry_getId(elem) ((elem)->id)
#define wbLogEntry_getSessionId(elem) ((elem)->session_id)
#define wbLogEntry_getMessage(elem) ((elem)->msg)
#define wbLogEntry_getMPIRank(elem) ((elem)->mpiRank)
#define wbLogEntry_getTime(elem) ((elem)->time)
#define wbLogEntry_getLevel(elem) ((elem)->level)
#define wbLogEntry_getNext(elem) ((elem)->next)
#define wbLogEntry_getLine(elem) ((elem)->line)
#define wbLogEntry_getFunction(elem) ((elem)->fun)
#define wbLogEntry_getFile(elem) ((elem)->file)
#define wbLogEntry_setId(elem, val) (wbLogEntry_getId(elem) = val)
#define wbLogEntry_setSessionId(elem, val) \
(wbLogEntry_getSessionId(elem) = val)
#define wbLogEntry_setMessage(elem, val) \
(wbLogEntry_getMessage(elem) = val)
#define wbLogEntry_setMPIRank(elem, val) \
(wbLogEntry_getMPIRank(elem) = val)
#define wbLogEntry_setTime(elem, val) (wbLogEntry_getTime(elem) = val)
#define wbLogEntry_setLevel(elem, val) (wbLogEntry_getLevel(elem) = val)
#define wbLogEntry_setNext(elem, val) (wbLogEntry_getNext(elem) = val)
#define wbLogEntry_setLine(elem, val) (wbLogEntry_getLine(elem) = val)
#define wbLogEntry_setFunction(elem, val) \
(wbLogEntry_getFunction(elem) = val)
#define wbLogEntry_setFile(elem, val) (wbLogEntry_getFile(elem) = val)
#define wbLogger_getId(log) ((log)->id)
#define wbLogger_getSessionId(log) ((log)->session_id)
#define wbLogger_getLength(log) ((log)->length)
#define wbLogger_getHead(log) ((log)->head)
#define wbLogger_getLevel(log) ((log)->level)
#define wbLogger_setId(log, val) (wbLogger_getId(log) = val)
#define wbLogger_setSessionId(log, val) (wbLogger_getSessionId(log) = val)
#define wbLogger_setLength(log, val) (wbLogger_getLength(log) = val)
#define wbLogger_setHead(log, val) (wbLogger_getHead(log) = val)
#define wbLogger_incrementLength(log) (wbLogger_getLength(log)++)
#define wbLogger_decrementLength(log) (wbLogger_getLength(log)--)
#define wbLog(level, ...) \
wbLogger_append(wbLogLevel_##level, wbString(__VA_ARGS__), wbFile, \
wbFunction, wbLine)
extern wbLogger_t _logger;
wbLogger_t wbLogger_new();
void wbLogger_clear(wbLogger_t logger);
void wbLogger_delete(wbLogger_t logger);
void wbLogger_append(wbLogLevel_t level, string msg, const char *file,
const char *fun, int line);
string wbLogger_toXML(wbLogger_t logger);
string wbLogger_toXML();
string wbLogger_toJSON(wbLogger_t logger);
string wbLogger_toJSON();
#endif /* __WB_LOGGER_H__ */