if log level is "error", print log to stderr instead of stdout (#57)

This commit is contained in:
Ozan Tezcan 2021-03-08 03:54:51 +03:00 committed by GitHub
parent ca520dd749
commit f19158c3d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -320,13 +320,14 @@ static int sc_log_print_header(FILE *fp, enum sc_log_level level)
static int sc_log_stdout(enum sc_log_level level, const char *fmt, va_list va)
{
int rc;
FILE *dest = level == SC_LOG_ERROR ? stderr : stdout;
rc = sc_log_print_header(stdout, level);
rc = sc_log_print_header(dest, level);
if (rc < 0) {
return -1;
}
rc = vfprintf(stdout, fmt, va);
rc = vfprintf(dest, fmt, va);
if (rc < 0) {
return -1;
}