This commit is contained in:
2024-11-28 18:30:27 +08:00
parent b2eec437cd
commit e04a960777
6 changed files with 17 additions and 17 deletions

View File

@@ -50,7 +50,7 @@ static void outputFileHandler(log_Handler *handler, const char *message) {
changeFile(handler);
}
log_Handler *loggingHandlerFile(const char *name, unsigned int max_size) {
log_Handler *loggingHandlerFile(const char *file_name, unsigned int max_size) {
char new_file_name[FILE_NAME_MAX_SIZE];
int suffix = 0;
unsigned int file_size;
@@ -60,7 +60,7 @@ log_Handler *loggingHandlerFile(const char *name, unsigned int max_size) {
/// 获取未写满于设置最大文件大小的文件名
do {
sprintf(new_file_name, "%s_%d.log", name, suffix++);
sprintf(new_file_name, "%s_%d.log", file_name, suffix++);
fp = fopen(new_file_name, "at");
if (fp == NULL)
goto ERROR;
@@ -77,7 +77,7 @@ log_Handler *loggingHandlerFile(const char *name, unsigned int max_size) {
handler_ex->file_size_max = max_size;
handler_ex->file_size = file_size;
handler_ex->suffix = suffix;
handler_ex->file_name = strdup(name);
handler_ex->file_name = strdup(file_name);
if (handler_ex->file_name == NULL)
goto ERROR;

View File

@@ -104,10 +104,10 @@ static void output_to_handler(log_Handler *handler,
* @param ... 格式化参数列表
* @return
*/
static void _builtin_cope(log_level level_e,
char *level,
const char *color,
const char *message) {
static void log_cope(log_level level_e,
char *level,
const char *color,
const char *message) {
if (G_LOGGER == NULL) {
return;
}
@@ -136,7 +136,7 @@ void log_fatal(const char *message, ...) {
va_start(args, message);
vsprintf(logStr, message, args);
va_end(args);
_builtin_cope(LOG_FATAL, "Fatal", RED_B, logStr);
log_cope(LOG_FATAL, "Fatal", RED_B, logStr);
}
}
@@ -147,7 +147,7 @@ void log_error(const char *message, ...) {
va_start(args, message);
vsprintf(logStr, message, args);
va_end(args);
_builtin_cope(LOG_ERROR, "Error", RED, logStr);
log_cope(LOG_ERROR, "Error", RED, logStr);
}
}
@@ -158,7 +158,7 @@ void log_warning(const char *message, ...) {
va_start(args, message);
vsprintf(logStr, message, args);
va_end(args);
_builtin_cope(LOG_WARNING, "Warning", YELLOW, logStr);
log_cope(LOG_WARNING, "Warning", YELLOW, logStr);
}
}
@@ -169,7 +169,7 @@ void log_info(const char *message, ...) {
va_start(args, message);
vsprintf(logStr, message, args);
va_end(args);
_builtin_cope(LOG_INFO, "Info", GREEN, logStr);
log_cope(LOG_INFO, "Info", GREEN, logStr);
}
}
@@ -180,7 +180,7 @@ void log_debug(const char *message, ...) {
va_start(args, message);
vsprintf(logStr, message, args);
va_end(args);
_builtin_cope(LOG_DEBUG, "Debug", CYAN, logStr);
log_cope(LOG_DEBUG, "Debug", CYAN, logStr);
}
}