-
Notifications
You must be signed in to change notification settings - Fork 9
API Document : flog
Yuzhang Hu edited this page Apr 11, 2017
·
4 revisions
-
FLOG_F_ASYNC: Enable asynchronization logging. -
FLOG_F_DEBUG: Enable debugging, add more debugging content into logs.
flog_file_t* flog_create(const char *filename, int flags)- brief: Create Logger.
- param:
filenamelog filename - param:
flagsFLOG_F_ASYNC, FLOG_F_DEBUG - return: a pointer of log_file structure
void flog_destroy(flog_file_t *logger)- brief: Destroy Logger.
- param:
loggerwhich will be destroy - return: void
size_t flog_write(flog_file_t *, const char *log, size_t len)- brief: Write log.
- param:
loglog message - param:
lenlength of message - return:
- 0: success
- 1: failed
void flog_writef(flog_file_t *, const char *fmt,...)- brief: Write log with format.
- param:
fmtformat string - param:
...dynamic args for format - return: void
void flog_vwritef(flog_file_t *, const char *fmt, va_list ap)- brief: Write log with format by a va_list.
- param:
fmtformat string - param:
apdynamic arg list using by the fmt - return: actual writen size
void flog_set_cookie(const char *fmt,...)- brief: Set log cookie, user set up once, then every log will include this cookie string.
- note: Cookie string is per-thread, and the max length of cookie is 256 bytes
- param:
fmtstring format - return: void
void flog_vset_cookie(const char *fmt, va_list ap)- brief: Set log cookie, user set up once, then every log will include this cookie string.
- note: Cookie string is per-thread, and the max length of cookie is 256 bytes
- param:
fmtstring format - param:
apdynamic arg list using by fmt - return: void
void flog_clear_cookie()- brief: Clear the cookie string.
- note: Clear action only impact the current thread cookie data
- return: void
void flog_set_roll_size(size_t size)- brief: Set file roll size, when greater than the given size, log system will roll a new file to continue writing messages, default value is 2G.
- param:
sizeset max size for rolling - return: void
void flog_set_flush_interval(time_t sec)- brief: Set max flush interval, unit second.
- param:
secafter given time, it will force to flush, default value is 0 - return: void
void flog_set_buffer_size(size_t size)- brief: Set buffer size for per user thread, should set before async writing The default buffer size per thread is 10M, call this interface if you want to change it.
- param:
sizebuffer size per thread - return: void
size_t flog_get_buffer_size()- brief: Get buffer size of per user thread.
- return: buffer size
void flog_register_event_callback(flog_event_func pfunc)- brief: Register a callback function for notifying user some important status.
- param:
pfuncuser callback function - return: void