diff mbox

[PATCHv3] linux-generic: only print errors to stderr

Message ID 1425648292-5753-1-git-send-email-stuart.haslam@linaro.org
State Accepted
Commit 49127831eb8ae2a16860af1fcb39abce68d495b4
Headers show

Commit Message

Stuart Haslam March 6, 2015, 1:24 p.m. UTC
The default logger prints all log levels to stderr. To make things
easier when debugging failures change it to print only errors to stderr
and everything else to stdout.

Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
Reviewed-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
---
v2: Fixed indentation (forgot to checkpatch v1)
v3: Removed ODP_UNUSED for level as it's now used

 platform/linux-generic/odp_weak.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

Comments

Stuart Haslam March 11, 2015, 2:21 p.m. UTC | #1
On Fri, Mar 06, 2015 at 01:24:52PM +0000, Stuart Haslam wrote:
> The default logger prints all log levels to stderr. To make things
> easier when debugging failures change it to print only errors to stderr
> and everything else to stdout.

ping - this is ready to be merged.

> 
> Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
> Reviewed-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
> ---
> v2: Fixed indentation (forgot to checkpatch v1)
> v3: Removed ODP_UNUSED for level as it's now used
> 
>  platform/linux-generic/odp_weak.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/platform/linux-generic/odp_weak.c b/platform/linux-generic/odp_weak.c
> index 7fa5955..f4336f0 100644
> --- a/platform/linux-generic/odp_weak.c
> +++ b/platform/linux-generic/odp_weak.c
> @@ -10,13 +10,24 @@
>  #include <odp/hints.h>
>  
>  ODP_WEAK_SYMBOL ODP_PRINTF_FORMAT(2, 3)
> -int odp_override_log(odp_log_level_e level ODP_UNUSED, const char *fmt, ...)
> +int odp_override_log(odp_log_level_e level, const char *fmt, ...)
>  {
>  	va_list args;
>  	int r;
> +	FILE *logfd;
> +
> +	switch (level) {
> +	case ODP_LOG_ERR:
> +	case ODP_LOG_UNIMPLEMENTED:
> +	case ODP_LOG_ABORT:
> +		logfd = stderr;
> +		break;
> +	default:
> +		logfd = stdout;
> +	}
>  
>  	va_start(args, fmt);
> -	r = vfprintf(stderr, fmt, args);
> +	r = vfprintf(logfd, fmt, args);
>  	va_end(args);
>  
>  	return r;
> -- 
> 2.1.1
>
Maxim Uvarov March 12, 2015, 8:21 a.m. UTC | #2
Merged,
Maxim.

On 03/06/15 16:24, Stuart Haslam wrote:
> The default logger prints all log levels to stderr. To make things
> easier when debugging failures change it to print only errors to stderr
> and everything else to stdout.
>
> Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
> Reviewed-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
> ---
> v2: Fixed indentation (forgot to checkpatch v1)
> v3: Removed ODP_UNUSED for level as it's now used
>
>   platform/linux-generic/odp_weak.c | 15 +++++++++++++--
>   1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/platform/linux-generic/odp_weak.c b/platform/linux-generic/odp_weak.c
> index 7fa5955..f4336f0 100644
> --- a/platform/linux-generic/odp_weak.c
> +++ b/platform/linux-generic/odp_weak.c
> @@ -10,13 +10,24 @@
>   #include <odp/hints.h>
>   
>   ODP_WEAK_SYMBOL ODP_PRINTF_FORMAT(2, 3)
> -int odp_override_log(odp_log_level_e level ODP_UNUSED, const char *fmt, ...)
> +int odp_override_log(odp_log_level_e level, const char *fmt, ...)
>   {
>   	va_list args;
>   	int r;
> +	FILE *logfd;
> +
> +	switch (level) {
> +	case ODP_LOG_ERR:
> +	case ODP_LOG_UNIMPLEMENTED:
> +	case ODP_LOG_ABORT:
> +		logfd = stderr;
> +		break;
> +	default:
> +		logfd = stdout;
> +	}
>   
>   	va_start(args, fmt);
> -	r = vfprintf(stderr, fmt, args);
> +	r = vfprintf(logfd, fmt, args);
>   	va_end(args);
>   
>   	return r;
diff mbox

Patch

diff --git a/platform/linux-generic/odp_weak.c b/platform/linux-generic/odp_weak.c
index 7fa5955..f4336f0 100644
--- a/platform/linux-generic/odp_weak.c
+++ b/platform/linux-generic/odp_weak.c
@@ -10,13 +10,24 @@ 
 #include <odp/hints.h>
 
 ODP_WEAK_SYMBOL ODP_PRINTF_FORMAT(2, 3)
-int odp_override_log(odp_log_level_e level ODP_UNUSED, const char *fmt, ...)
+int odp_override_log(odp_log_level_e level, const char *fmt, ...)
 {
 	va_list args;
 	int r;
+	FILE *logfd;
+
+	switch (level) {
+	case ODP_LOG_ERR:
+	case ODP_LOG_UNIMPLEMENTED:
+	case ODP_LOG_ABORT:
+		logfd = stderr;
+		break;
+	default:
+		logfd = stdout;
+	}
 
 	va_start(args, fmt);
-	r = vfprintf(stderr, fmt, args);
+	r = vfprintf(logfd, fmt, args);
 	va_end(args);
 
 	return r;