summaryrefslogtreecommitdiff
path: root/src/include/MESA_handle_logger.h
blob: 567624a60857514d9cdebf2c31e4331fe69a8f85 (plain)
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
101
102
103
104
105
106
107
#ifndef MESA_HANDLE__LOGGER_H
#define MESA_HANDLE__LOGGER_H

/*
 * runtime_log with handle,
 * based on runtime_log.
 * yang wei
 * create time:2014-03-24
 * version:20140324
 */

#ifdef __cplusplus
extern "C"
{
#endif

#define RLOG_LV_DEBUG       10
#define RLOG_LV_INFO        20
#define RLOG_LV_FATAL       30


#define MESA_HANDLE_RUNTIME_LOG(handle, lv, mod, fmt, args...)   \
    MESA_handle_runtime_log((handle), (lv), (mod), "file %s, line %d, " fmt, \
                       __FILE__, __LINE__, ##args)

/*
 * name: MESA_create_runtime_log_handle
 * functionality: get runtime_log handle;
 * params:
 *  file_path: path of log file, like "./log/runtime_log";
 *  level: level of log, you can only use 3 levels: RLOG_LV_DEBUG, RLOG_LV_INFO, RLOG_LV_FATAL; 
 * returns:
 *  not NULL, if succeeded;
 *   NULL, if file is not absolute path, or failed to create log file;
 */
void *MESA_create_runtime_log_handle(const char *file_path, int level);

/*
 * name: MESA_create_runtime_log_handle_new
 * functionality: get runtime_log handle, it depends on easylogging++.
 *    we recommend you to use the new constructed function;;
 * params:
 *  logger_id: indentify a handle;
 *  no parameter level, we recommand you to use MESA_set_runtime_log_handle_opt to enable or disable a level
 * returns:
 *  not NULL, if succeeded;
 *   NULL, if logger_id == NULL or level is invalid;
 */
void* MESA_create_runtime_log_handle_new(const char* logger_id);

/*
 * name: MESA_handle_runtime_log
 * functionality: appends log message to runtime log file;
 * params:
 *  handle: handle of runtime log, which is created by MESA_create_runtime_log_handle;
 *  level: log level, messages with level value smaller the global var
 *      "runtime_log_level" are ignored;
 *  module: name of loggin module;
 *  fmt: format string;
 * returns:
 *  none;
 */
void MESA_handle_runtime_log(void *handle, int level, const char *module, const char *fmt, ...);

 /*
 * name: MESA_read_handle_runtime_log_conf
 * functionality: read and set the conf of a handle;
 * params:
 *  handle: handle of runtime log;
 *  conf_file_path: path of the conf file;
 * returns:
 *   0, if succeeded;
 *   -1, if failed; 
 */
int MESA_read_runtime_log_handle_conf(void* handle, const char* conf_file_path);

/*
 * name: MESA_set_runtime_log_handle_opt
 * functionality: set option of a runtime_log_handle;
 * params:
 *  handle: handle of runtime log;
 *  level: log level;
 *  key: key of option ;
 *  value: value of option;
 * returns:
 *   0, if succeeded;
 *   -1, if failed; 
 */
int MESA_set_runtime_log_handle_opt(void* handle, int level, const char* key, const char* value);

/*
 * name: MESA_destroy_runtime_log_handle
 * functionality: release runtime log handle memory.
 * params:
 *  handle: runtime log handle which is going to be released;
 * returns:
 *  none;
 */
void MESA_destroy_runtime_log_handle(void *handle);

#ifdef __cplusplus
}
#endif

#endif