| 79 |
{ |
{ |
| 80 |
snprintf(buf, len, "[%s] [%d] [INFO] ", s_time, getpid()); |
snprintf(buf, len, "[%s] [%d] [INFO] ", s_time, getpid()); |
| 81 |
} |
} |
| 82 |
else // if (log_level == LOG_LEVEL_ERROR) |
else if (log_level == LOG_LEVEL_ERROR) |
| 83 |
{ |
{ |
| 84 |
snprintf(buf, len, "[%s] [%d] [ERROR] [%s:%d] ", s_time, getpid(), app_file, app_line); |
snprintf(buf, len, "[%s] [%d] [ERROR] [%s:%d] ", s_time, getpid(), app_file, app_line); |
| 85 |
} |
} |
| 86 |
|
else // if (log_level == LOG_LEVEL_DEBUG) |
| 87 |
|
{ |
| 88 |
|
snprintf(buf, len, "[%s] [%d] [DEBUG] [%s:%d] ", s_time, getpid(), app_file, app_line); |
| 89 |
|
} |
| 90 |
} |
} |
| 91 |
|
|
| 92 |
int log_printf(enum log_level_t log_level, const char *app_file, int app_line, const char *format, ...) |
int log_printf(enum log_level_t log_level, const char *app_file, int app_line, const char *format, ...) |
| 96 |
char buf[LINE_BUFFER_LEN]; |
char buf[LINE_BUFFER_LEN]; |
| 97 |
FILE *fp_log; |
FILE *fp_log; |
| 98 |
|
|
| 99 |
fp_log = (log_level == LOG_LEVEL_ERROR ? fp_error_log : fp_common_log); |
fp_log = (log_level == LOG_LEVEL_COMMON ? fp_common_log : fp_error_log); |
| 100 |
|
|
| 101 |
log_head(buf, sizeof(buf), log_level, app_file, app_line); |
log_head(buf, sizeof(buf), log_level, app_file, app_line); |
| 102 |
strncat(buf, format, sizeof(buf) - strnlen(buf, sizeof(buf))); |
strncat(buf, format, sizeof(buf) - strnlen(buf, sizeof(buf))); |