mirror of
https://github.com/armink/EasyLogger.git
synced 2025-01-31 13:32:52 +08:00
commit
9bacff022c
@ -31,10 +31,12 @@
|
||||
|
||||
/* enable log output. default open this macro */
|
||||
#define ELOG_OUTPUT_ENABLE
|
||||
/* enable terminal output. default open this macro */
|
||||
#define ELOG_TERMINAL_ENABLE
|
||||
/* enable log write file. default open this macro */
|
||||
#define ELOG_FILE_ENABLE
|
||||
/* enable flush file cache. default open this macro */
|
||||
#define ELOG_FILE_FLUSH_CAHCE_ENABLE
|
||||
#define ELOG_FILE_FLUSH_CACHE_ENABLE
|
||||
/* setting static output log level */
|
||||
#define ELOG_OUTPUT_LVL ELOG_LVL_VERBOSE
|
||||
/* enable assert check */
|
||||
@ -58,7 +60,7 @@
|
||||
/* the highest output level for async mode, other level will sync output */
|
||||
#define ELOG_ASYNC_OUTPUT_LVL ELOG_LVL_DEBUG
|
||||
/* buffer size for asynchronous output mode */
|
||||
#define ELOG_ASYNC_OUTPUT_BUF_SIZE (ELOG_LINE_BUF_SIZE * 100)
|
||||
#define ELOG_ASYNC_OUTPUT_BUF_SIZE (ELOG_LINE_BUF_SIZE * 50)
|
||||
/* each asynchronous output's log which must end with newline sign */
|
||||
//#define ELOG_ASYNC_LINE_OUTPUT
|
||||
/* asynchronous output mode using POSIX pthread implementation */
|
||||
|
@ -75,7 +75,10 @@ void elog_port_deinit(void) {
|
||||
*/
|
||||
void elog_port_output(const char *log, size_t size) {
|
||||
/* output to terminal */
|
||||
#ifdef ELOG_TERMINAL_ENABLE
|
||||
printf("%.*s", (int)size, log);
|
||||
#endif
|
||||
|
||||
#ifdef ELOG_FILE_ENABLE
|
||||
/* write the file */
|
||||
elog_file_write(log, size);
|
||||
|
@ -34,7 +34,7 @@
|
||||
/* enable log write file. default open this macro */
|
||||
#define ELOG_FILE_ENABLE
|
||||
/* enable flush file cache. default open this macro */
|
||||
#define ELOG_FILE_FLUSH_CAHCE_ENABLE
|
||||
#define ELOG_FILE_FLUSH_CACHE_ENABLE
|
||||
/* setting static output log level */
|
||||
#define ELOG_OUTPUT_LVL ELOG_LVL_VERBOSE
|
||||
/* enable assert check */
|
||||
|
@ -131,7 +131,7 @@ void elog_file_write(const char *log, size_t size)
|
||||
|
||||
fwrite(log, size, 1, fp);
|
||||
|
||||
#ifdef ELOG_FILE_FLUSH_CAHCE_ENABLE
|
||||
#ifdef ELOG_FILE_FLUSH_CACHE_ENABLE
|
||||
fflush(fp);
|
||||
#endif
|
||||
|
||||
|
@ -47,16 +47,22 @@
|
||||
#define ELOG_ASYNC_OUTPUT_PTHREAD_PRIORITY (sched_get_priority_max(SCHED_RR) - 1)
|
||||
#endif
|
||||
/* output thread poll get log buffer size */
|
||||
#ifndef ELOG_ASYNC_LINE_OUTPUT
|
||||
#ifndef ELOG_ASYNC_POLL_GET_LOG_BUF_SIZE
|
||||
#define ELOG_ASYNC_POLL_GET_LOG_BUF_SIZE (ELOG_ASYNC_OUTPUT_BUF_SIZE - 4)
|
||||
#endif
|
||||
#else
|
||||
#ifndef ELOG_ASYNC_POLL_GET_LOG_BUF_SIZE
|
||||
#define ELOG_ASYNC_POLL_GET_LOG_BUF_SIZE (ELOG_LINE_BUF_SIZE - 4)
|
||||
#endif
|
||||
#endif
|
||||
#endif /* ELOG_ASYNC_OUTPUT_USING_PTHREAD */
|
||||
|
||||
/* asynchronous output log notice */
|
||||
static sem_t output_notice;
|
||||
/* asynchronous output pthread thread */
|
||||
static pthread_t async_output_thread;
|
||||
#endif /* ELOG_ASYNC_OUTPUT_USING_PTHREAD */
|
||||
#endif /* ELOG_ASYNC_OUTPUT_ENABLE */
|
||||
|
||||
/* the highest output level for async mode, other level will sync output */
|
||||
#ifdef ELOG_ASYNC_OUTPUT_LVL
|
||||
|
Loading…
x
Reference in New Issue
Block a user