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

Message ID 1425558028-18028-1-git-send-email-stuart.haslam@linaro.org
State New
Headers show

Commit Message

Stuart Haslam March 5, 2015, 12:20 p.m.
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>
---
v2: Fixed indentation (forgot to checkpatch v1)

 platform/linux-generic/odp_weak.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Taras Kondratiuk March 5, 2015, 12:47 p.m. | #1
On 03/05/2015 02:20 PM, 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>
> ---
> v2: Fixed indentation (forgot to checkpatch v1)
>
>   platform/linux-generic/odp_weak.c | 13 ++++++++++++-
>   1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/platform/linux-generic/odp_weak.c b/platform/linux-generic/odp_weak.c
> index 7fa5955..145d0b8 100644
> --- a/platform/linux-generic/odp_weak.c
> +++ b/platform/linux-generic/odp_weak.c
> @@ -14,9 +14,20 @@ int odp_override_log(odp_log_level_e level ODP_UNUSED, const char *fmt, ...)

Remove ODP_UNUSED. Otherwise
Reviewed-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>

>   {
>   	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;
>
Stuart Haslam March 6, 2015, 1:18 p.m. | #2
On Thu, Mar 05, 2015 at 02:47:35PM +0200, Taras Kondratiuk wrote:
> On 03/05/2015 02:20 PM, 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>
> >---
> >v2: Fixed indentation (forgot to checkpatch v1)
> >
> >  platform/linux-generic/odp_weak.c | 13 ++++++++++++-
> >  1 file changed, 12 insertions(+), 1 deletion(-)
> >
> >diff --git a/platform/linux-generic/odp_weak.c b/platform/linux-generic/odp_weak.c
> >index 7fa5955..145d0b8 100644
> >--- a/platform/linux-generic/odp_weak.c
> >+++ b/platform/linux-generic/odp_weak.c
> >@@ -14,9 +14,20 @@ int odp_override_log(odp_log_level_e level ODP_UNUSED, const char *fmt, ...)
> 
> Remove ODP_UNUSED. Otherwise
> Reviewed-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
> 

Thanks. I'll send a v3 with ODP_UNUSED removed, well spotted.
Mike Holmes March 6, 2015, 1:26 p.m. | #3
We have removed a few ODP_UNUSED where they are used,  are we missing
something, you would think gcc would flag this

On 6 March 2015 at 08:18, Stuart Haslam <stuart.haslam@linaro.org> wrote:

> On Thu, Mar 05, 2015 at 02:47:35PM +0200, Taras Kondratiuk wrote:
> > On 03/05/2015 02:20 PM, 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>
> > >---
> > >v2: Fixed indentation (forgot to checkpatch v1)
> > >
> > >  platform/linux-generic/odp_weak.c | 13 ++++++++++++-
> > >  1 file changed, 12 insertions(+), 1 deletion(-)
> > >
> > >diff --git a/platform/linux-generic/odp_weak.c
> b/platform/linux-generic/odp_weak.c
> > >index 7fa5955..145d0b8 100644
> > >--- a/platform/linux-generic/odp_weak.c
> > >+++ b/platform/linux-generic/odp_weak.c
> > >@@ -14,9 +14,20 @@ int odp_override_log(odp_log_level_e level
> ODP_UNUSED, const char *fmt, ...)
> >
> > Remove ODP_UNUSED. Otherwise
> > Reviewed-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
> >
>
> Thanks. I'll send a v3 with ODP_UNUSED removed, well spotted.
>
> --
> Stuart.
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Stuart Haslam March 6, 2015, 1:36 p.m. | #4
On Fri, Mar 06, 2015 at 08:26:20AM -0500, Mike Holmes wrote:
> We have removed a few ODP_UNUSED where they are used,  are we missing
> something, you would think gcc would flag this
> 

I guess it doesn't as the unused attribute just means that it's
"possibly unused", which means it's also possibly used.

Not sure there is a way to catch these other than through manual
inspection.

Patch

diff --git a/platform/linux-generic/odp_weak.c b/platform/linux-generic/odp_weak.c
index 7fa5955..145d0b8 100644
--- a/platform/linux-generic/odp_weak.c
+++ b/platform/linux-generic/odp_weak.c
@@ -14,9 +14,20 @@  int odp_override_log(odp_log_level_e level ODP_UNUSED, 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;