[lxc-devel] [PATCH] add file/func/line to debug info

Serge Hallyn serge.hallyn at ubuntu.com
Mon Sep 29 17:26:15 UTC 2014


Quoting Stéphane Graber (stgraber at ubuntu.com):
> On Mon, Sep 29, 2014 at 04:14:28PM +0000, Serge Hallyn wrote:
> > 
> > Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
> 
> I wonder if we should have some kind of way to prevent this information
> from showing up for some cases, possibly adding a new log level called
> "HELP" which when used won't log the timestamp or anything
> debug-looking, then we can use that for some of those long messages we
> print for common configuration problems.

yeah that would be good.  User doesn't need those.

> Acked-by: Stéphane Graber <stgraber at ubuntu.com>
> 
> > ---
> >  src/lxc/log.c |    7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/src/lxc/log.c b/src/lxc/log.c
> > index e3c64ee..0fe376c 100644
> > --- a/src/lxc/log.c
> > +++ b/src/lxc/log.c
> > @@ -72,6 +72,7 @@ static int log_append_stderr(const struct lxc_log_appender *appender,
> >  		return 0;
> >  
> >  	fprintf(stderr, "%s: ", log_prefix);
> > +	fprintf(stderr, "%s: %s: %d ", event->locinfo->file, event->locinfo->func, event->locinfo->line);
> >  	vfprintf(stderr, event->fmt, *event->vap);
> >  	fprintf(stderr, "\n");
> >  	return 0;
> > @@ -90,12 +91,14 @@ static int log_append_logfile(const struct lxc_log_appender *appender,
> >  
> >  	ms = event->timestamp.tv_usec / 1000;
> >  	n = snprintf(buffer, sizeof(buffer),
> > -		     "%15s %10ld.%03d %-8s %s - ",
> > +		     "%15s %10ld.%03d %-8s %s - %s:%s:%d - ",
> >  		     log_prefix,
> >  		     event->timestamp.tv_sec,
> >  		     ms,
> >  		     lxc_log_priority_to_string(event->priority),
> > -		     event->category);
> > +		     event->category,
> > +		     event->locinfo->file, event->locinfo->func,
> > +		     event->locinfo->line);
> >  
> >  	n += vsnprintf(buffer + n, sizeof(buffer) - n, event->fmt,
> >  		       *event->vap);
> > -- 
> > 1.7.9.5
> > 
> > _______________________________________________
> > lxc-devel mailing list
> > lxc-devel at lists.linuxcontainers.org
> > http://lists.linuxcontainers.org/listinfo/lxc-devel
> 
> -- 
> Stéphane Graber
> Ubuntu developer
> http://www.ubuntu.com



> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel



More information about the lxc-devel mailing list