Skip to content

API Document : flog

Yuzhang Hu edited this page Apr 11, 2017 · 4 revisions

Macros

  • FLOG_F_ASYNC: Enable asynchronization logging.
  • FLOG_F_DEBUG: Enable debugging, add more debugging content into logs.

APIs

flog_create

flog_file_t* flog_create(const char *filename, int flags)
  • brief: Create Logger.
  • param: filename log filename
  • param: flags FLOG_F_ASYNC, FLOG_F_DEBUG
  • return: a pointer of log_file structure

flog_destroy

void flog_destroy(flog_file_t *logger)
  • brief: Destroy Logger.
  • param: logger which will be destroy
  • return: void

flog_write

size_t flog_write(flog_file_t *, const char *log, size_t len)
  • brief: Write log.
  • param: log log message
  • param: len length of message
  • return:
    • 0: success
    • 1: failed

flog_writef

void flog_writef(flog_file_t *, const char *fmt,...)
  • brief: Write log with format.
  • param: fmt format string
  • param: ... dynamic args for format
  • return: void

flog_vwritef

void flog_vwritef(flog_file_t *, const char *fmt, va_list ap)
  • brief: Write log with format by a va_list.
  • param: fmt format string
  • param: ap dynamic arg list using by the fmt
  • return: actual writen size

flog_set_cookie

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: fmt string format
  • return: void

flog_vset_cookie

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: fmt string format
  • param: ap dynamic arg list using by fmt
  • return: void

flog_clear_cookie

void flog_clear_cookie()
  • brief: Clear the cookie string.
  • note: Clear action only impact the current thread cookie data
  • return: void

flog_set_roll_size

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: size set max size for rolling
  • return: void

flog_set_flush_interval

void flog_set_flush_interval(time_t sec)
  • brief: Set max flush interval, unit second.
  • param: sec after given time, it will force to flush, default value is 0
  • return: void

flog_set_buffer_size

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: size buffer size per thread
  • return: void

flog_get_buffer_size

size_t flog_get_buffer_size()
  • brief: Get buffer size of per user thread.
  • return: buffer size

flog_register_event_callback

void flog_register_event_callback(flog_event_func pfunc)
  • brief: Register a callback function for notifying user some important status.
  • param: pfunc user callback function
  • return: void

Clone this wiki locally