From f04439e0ac1b493814f50c90229abcb140401288 Mon Sep 17 00:00:00 2001 From: Ted John Date: Wed, 7 Jun 2017 07:39:18 +0100 Subject: [PATCH] Use stdout for verbose and info logging (#5563) Only errors and warnings should be piped to stderr. --- src/openrct2/diagnostic.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/openrct2/diagnostic.c b/src/openrct2/diagnostic.c index 4018dedcaf..569d99b334 100644 --- a/src/openrct2/diagnostic.c +++ b/src/openrct2/diagnostic.c @@ -30,15 +30,25 @@ const char * _level_strings[] = { "INFO" }; +static FILE * diagnostic_get_stream(DiagnosticLevel level) +{ + switch (level) { + case DIAGNOSTIC_LEVEL_VERBOSE: + case DIAGNOSTIC_LEVEL_INFORMATION: + return stdout; + default: + return stderr; + } +} + void diagnostic_log(DiagnosticLevel diagnosticLevel, const char *format, ...) { - FILE *stream; va_list args; if (!_log_levels[diagnosticLevel]) return; - stream = stderr; + FILE * stream = diagnostic_get_stream(diagnosticLevel); // Level fprintf(stream, "%s: ", _level_strings[diagnosticLevel]); @@ -54,13 +64,12 @@ void diagnostic_log(DiagnosticLevel diagnosticLevel, const char *format, ...) void diagnostic_log_with_location(DiagnosticLevel diagnosticLevel, const char *file, const char *function, sint32 line, const char *format, ...) { - FILE *stream; va_list args; if (!_log_levels[diagnosticLevel]) return; - stream = stderr; + FILE * stream = diagnostic_get_stream(diagnosticLevel); // Level and source code information if (_log_location_enabled)