--- lbbs/src/log.c 2025/06/17 13:17:04 1.25 +++ lbbs/src/log.c 2025/11/16 00:19:42 1.32 @@ -1,34 +1,33 @@ -/*************************************************************************** - log.c - description - ------------------- - Copyright : (C) 2004-2025 by Leaflet - Email : leaflet@leafok.com - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * log + * - logger + * + * Copyright (C) 2004-2025 Leaflet + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -#include "log.h" -#include "io.h" #include "common.h" +#include "io.h" +#include "log.h" #include #include #include #include #include -#define STR_LOG_TIME_MAX_LEN 50 +enum _log_constant_t +{ + STR_LOG_TIME_MAX_LEN = 50, +}; static FILE *fp_common_log; static FILE *fp_error_log; -int log_begin(char *common_log_file, char *error_log_file) +int log_begin(const char *common_log_file, const char *error_log_file) { fp_common_log = fopen(common_log_file, "a"); if (fp_common_log == NULL) @@ -73,7 +72,7 @@ inline static void log_head(char *buf, s } } -int log_printf(int 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, ...) { va_list args; int retval; @@ -96,16 +95,10 @@ int log_printf(int log_level, const char int log_common_redir(int fd) { - int ret; - close(fileno(fp_common_log)); - ret = dup2(fd, fileno(fp_common_log)); - return ret; + return dup2(fd, fileno(fp_common_log)); } int log_error_redir(int fd) { - int ret; - close(fileno(fp_error_log)); - ret = dup2(fd, fileno(fp_error_log)); - return ret; + return dup2(fd, fileno(fp_error_log)); }