Merge remote-tracking branch 'origin/feat/rsync-stderr-mode' into dev
# Conflicts: # RSYNC_COMPAT.md # src/shared/log.c # src/shared/log.h # tests/test_client_cli.c
This commit is contained in:
+10
-1
@@ -9,6 +9,7 @@ static const char* log_level_strings[] = {"DEBUG", "INFO", "WARN", "ERROR"};
|
||||
static LogLevel current_log_level = LOG_LEVEL_WARNING;
|
||||
static FILE* log_fp = NULL;
|
||||
static _Thread_local bool eight_bit_output;
|
||||
static LogStderrMode stderr_mode = LOG_STDERR_ERRORS;
|
||||
|
||||
void set_log_level(LogLevel level) {
|
||||
current_log_level = level;
|
||||
@@ -26,6 +27,14 @@ bool log_get_8_bit_output(void) {
|
||||
return eight_bit_output;
|
||||
}
|
||||
|
||||
void log_set_stderr_mode(LogStderrMode mode) {
|
||||
stderr_mode = mode;
|
||||
}
|
||||
|
||||
LogStderrMode log_get_stderr_mode(void) {
|
||||
return stderr_mode;
|
||||
}
|
||||
|
||||
static inline void write_message(FILE* dest_io, LogLevel log_level, struct tm t, const char* format,
|
||||
va_list args) {
|
||||
fprintf(dest_io, "%04d-%02d-%02d %02d:%02d:%02d [%s]: ", t.tm_year + 1900, t.tm_mon + 1,
|
||||
@@ -46,7 +55,7 @@ void log_message(LogLevel log_level, const char* format, ...) {
|
||||
return;
|
||||
|
||||
FILE* dest_io = stdout;
|
||||
if (log_level == LOG_LEVEL_ERROR) {
|
||||
if (stderr_mode == LOG_STDERR_ALL || log_level == LOG_LEVEL_ERROR) {
|
||||
dest_io = stderr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user