86 lines
2.3 KiB
C
86 lines
2.3 KiB
C
#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
|
|
|
|
#include <pthread.h>
|
|
|
|
#define MESA_PTHREAD_CACHE_BUF_DEFAULT_LEN 1024
|
|
#define MESA_PTHREAD_FMT_BUF_DEFAULT_LEN 256
|
|
extern pthread_key_t MESA_pthread_key;
|
|
void MESA_pthread_free_handler(void *arg);
|
|
|
|
typedef int (*MESA_fmt_handler)(void *info, char *buf, int buflen);
|
|
int MESA_handle_fmt_rule_register(void *handle, char sign, MESA_fmt_handler handler, int buflen);
|
|
int MESA_handle_check_fmt_sign(void *handle, char sign, MESA_fmt_handler *handler, char **buf, int *maxlen);
|
|
void MESA_free_pthread_private(void *arg);
|
|
|
|
|
|
#define RLOG_LV_DEBUG 10
|
|
#define RLOG_LV_INFO 20
|
|
#define RLOG_LV_FATAL 30
|
|
|
|
|
|
int MESA_handle_runtime_log_creation(const char *conf_path);
|
|
int MESA_handle_runtime_log_reconstruction(const char *conf_path);
|
|
void MESA_handle_runtime_log_destruction(void);
|
|
|
|
#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;
|
|
* 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_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_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
|
|
|
|
|