Support audit
This commit is contained in:
79
src/tlog.h
79
src/tlog.h
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* tinylog
|
||||
* Copyright (C) 2018 Ruilin Peng (Nick) <pymumu@gmail.com>
|
||||
* tinylog
|
||||
* Copyright (C) 2018 Ruilin Peng (Nick) <pymumu@gmail.com>
|
||||
* https://github.com/pymumu/tinylog
|
||||
*/
|
||||
|
||||
@@ -41,16 +41,17 @@ struct tlog_info {
|
||||
};
|
||||
|
||||
/*
|
||||
Function:Print log
|
||||
level: Current log Levels
|
||||
format: Log formats
|
||||
Function: Print log
|
||||
level: Current log Levels
|
||||
format: Log formats
|
||||
*/
|
||||
#ifndef BASE_FILE_NAME
|
||||
#define BASE_FILE_NAME __FILE__
|
||||
#endif
|
||||
#define tlog(level, format, ...) tlog_ext(level, BASE_FILE_NAME, __LINE__, __func__, 0, format, ##__VA_ARGS__)
|
||||
|
||||
extern int tlog_ext(tlog_level level, const char *file, int line, const char *func, void *userptr, const char *format, ...) __attribute__((format(printf, 6, 7)));
|
||||
extern int tlog_ext(tlog_level level, const char *file, int line, const char *func, void *userptr, const char *format, ...)
|
||||
__attribute__((format(printf, 6, 7)));
|
||||
extern int tlog_vext(tlog_level level, const char *file, int line, const char *func, void *userptr, const char *format, va_list ap);
|
||||
|
||||
/* set log level */
|
||||
@@ -59,19 +60,22 @@ extern int tlog_setlevel(tlog_level level);
|
||||
/* enalbe log to screen */
|
||||
extern void tlog_setlogscreen(int enable);
|
||||
|
||||
/*
|
||||
Function:Initialize log module
|
||||
logdir: Log Output path.
|
||||
logname: Log name.
|
||||
maxlogsize: The maximum size of a single log file.
|
||||
maxlogcount: Number of archived logs.
|
||||
block: Blocked if buffer is not sufficient.
|
||||
buffsize: Buffer size, zero for default (128K)
|
||||
multiwrite: enable multi process write mode.
|
||||
NOTICE: maxlogsize in all prcesses must be same when enable this mode.
|
||||
*/
|
||||
extern int tlog_init(const char *logdir, const char *logname, int maxlogsize, int maxlogcount, int block, int buffsize, int multiwrite);
|
||||
/* enalbe early log to screen */
|
||||
extern void tlog_set_early_printf(int enable);
|
||||
|
||||
/*
|
||||
Function: Initialize log module
|
||||
logfile: log file.
|
||||
maxlogsize: The maximum size of a single log file.
|
||||
maxlogcount: Number of archived logs.
|
||||
block: Blocked if buffer is not sufficient.
|
||||
buffsize: Buffer size, zero for default (128K)
|
||||
multiwrite: enable multi process write mode.
|
||||
NOTICE: maxlogsize in all prcesses must be same when enable this mode.
|
||||
*/
|
||||
extern int tlog_init(const char *logfile, int maxlogsize, int maxlogcount, int block, int buffsize, int multiwrite);
|
||||
|
||||
/* flush pending log message, and exit tlog */
|
||||
extern void tlog_exit(void);
|
||||
|
||||
/*
|
||||
@@ -85,6 +89,45 @@ read _tlog_format for example.
|
||||
typedef int (*tlog_format_func)(char *buff, int maxlen, struct tlog_info *info, void *userptr, const char *format, va_list ap);
|
||||
extern int tlog_reg_format_func(tlog_format_func func);
|
||||
|
||||
struct tlog_log;
|
||||
typedef struct tlog_log tlog_log;
|
||||
/*
|
||||
Function: open a new log stream, handler should close by tlog_close
|
||||
logfile: log file.
|
||||
maxlogsize: The maximum size of a single log file.
|
||||
maxlogcount: Number of archived logs.
|
||||
block: Blocked if buffer is not sufficient.
|
||||
buffsize: Buffer size, zero for default (128K)
|
||||
multiwrite: enable multi process write mode.
|
||||
NOTICE: maxlogsize in all prcesses must be same when enable this mode.
|
||||
|
||||
return: log stream handler.
|
||||
*/
|
||||
extern tlog_log *tlog_open(const char *logfile, int maxlogsize, int maxlogcount, int block, int buffsize, int multiwrite);
|
||||
|
||||
extern void tlog_close(tlog_log *log);
|
||||
|
||||
/*
|
||||
Function: Print log to log stream
|
||||
log: log stream
|
||||
format: Log formats
|
||||
*/
|
||||
extern int tlog_printf(tlog_log *log, const char *format, ...) __attribute__((format(printf, 2, 3)));
|
||||
|
||||
/*
|
||||
Function: Print log to log stream with ap
|
||||
log: log stream
|
||||
format: Log formats
|
||||
va_list: args list
|
||||
*/
|
||||
extern int tlog_vprintf(tlog_log *log, const char *format, va_list ap);
|
||||
|
||||
/* enalbe log to screen */
|
||||
extern void tlog_logscreen(tlog_log *log, int enable);
|
||||
|
||||
/* get local time */
|
||||
extern int tlog_localtime(struct tlog_time *tm);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus */
|
||||
|
||||
Reference in New Issue
Block a user