nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: "Qi, Fuli" <qi.fuli@jp.fujitsu.com>
To: 'Masayoshi Mizuma' <msys.mizuma@gmail.com>,
	"linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>
Subject: RE: [ndctl PATCH 3/4] ndctl, monitor: add timestamp and pid to log messages in log_file()
Date: Wed, 8 Aug 2018 00:54:50 +0000	[thread overview]
Message-ID: <0DEDF3B159719A448A49EF0E7B11E3223DA9DCE5@g01jpexmbkw24> (raw)
In-Reply-To: <bed6c181-1316-4506-c2b6-113eea1f13ce@gmail.com>

> -----Original Message-----
> From: Masayoshi Mizuma [mailto:msys.mizuma@gmail.com]
> Sent: Wednesday, August 8, 2018 3:40 AM
> To: Qi, Fuli/斉 福利 <qi.fuli@jp.fujitsu.com>; linux-nvdimm@lists.01.org
> Subject: Re: [ndctl PATCH 3/4] ndctl, monitor: add timestamp and pid to log messages
> in log_file()
> 
> Hi Qi,
> 
> On 08/07/2018 09:17 AM, QI Fuli wrote:
> > This patch is used to add timestamp and process id to log messages
> > when logging messages to a file.
> >
> > Signed-off-by: QI Fuli <qi.fuli@jp.fujitsu.com>
> > ---
> >  ndctl/monitor.c | 11 ++++++++++-
> >  1 file changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/ndctl/monitor.c b/ndctl/monitor.c index 2f3d751..d29e378
> > 100644
> > --- a/ndctl/monitor.c
> > +++ b/ndctl/monitor.c
> > @@ -84,6 +84,8 @@ static void log_file(struct ndctl_ctx *ctx, int
> > priority, const char *file,  {
> >  	FILE *f;
> >  	char *buf;
> > +	struct timespec ts;
> > +	char timestamp[32];
> >
> >  	if (vasprintf(&buf, format, args) < 0) {
> >  		fail("vasprintf error\n");
> > @@ -99,7 +101,14 @@ static void log_file(struct ndctl_ctx *ctx, int priority, const
> char *file,
> >  		notice(ctx, "%s\n", buf);
> >  		goto end;
> >  	}
> > -	fprintf(f, "%s", buf);
> > +
> > +	if (priority != LOG_NOTICE) {
> 
Hi Masa,

Thanks for your comments.

> Why is the timestamp not needed in case of LOG_NOTICE...?

Because LOG_NOTICE level is only used for smart event notification in monitor.
Since the timestamp and pid are already added to json format messages by notify_dimm_event(),
so there is no need to add them again.

> 
> > +		clock_gettime(CLOCK_REALTIME, &ts);
> > +		sprintf(timestamp, "%10ld.%09ld", ts.tv_sec, ts.tv_nsec);
> > +		fprintf(f, "[%s] [%d] %s", timestamp, getpid(), buf);
> 
> What is the pid for...?
> 
Multiple monitor can be run at the same time and they may send messages to a common log file.
In this case, the pid could help users to know the monitor where each message came from.

Thanks,
QI

> Thanks,
> Masa
> 
> > +	} else
> > +		fprintf(f, "%s", buf);
> > +>  	fflush(f);
> >  	fclose(f);
> >  end:
> >
> 

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

  reply	other threads:[~2018-08-08  0:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-07 13:17 [ndctl PATCH 0/4] Some fixups and improvements ndctl monitor QI Fuli
2018-08-07 13:17 ` [ndctl PATCH 1/4] ndctl, monitor: fix the lack of detection of invalid path of log file QI Fuli
2018-08-07 19:05   ` Masayoshi Mizuma
2018-08-08  1:01     ` Qi, Fuli
2018-08-07 13:17 ` [ndctl PATCH 2/4] ndctl, monitor: set default log destination to syslog if "--daemon" is specified QI Fuli
2018-08-07 19:30   ` Masayoshi Mizuma
2018-08-08  1:31     ` Qi, Fuli
2018-08-08 13:35       ` Masayoshi Mizuma
2018-08-08 15:59         ` Qi, Fuli
2018-08-08 16:24           ` Masayoshi Mizuma
2018-08-07 13:17 ` [ndctl PATCH 3/4] ndctl, monitor: add timestamp and pid to log messages in log_file() QI Fuli
2018-08-07 18:39   ` Masayoshi Mizuma
2018-08-08  0:54     ` Qi, Fuli [this message]
2018-08-08  1:24       ` Masayoshi Mizuma
2018-08-07 13:17 ` [ndctl PATCH 4/4] ndctl, monitor: add [Install] Section to systemd unit file of ndctl-monitor QI Fuli
2018-08-07 18:41   ` Masayoshi Mizuma
2018-08-10 20:42 ` [ndctl PATCH 0/4] Some fixups and improvements ndctl monitor Verma, Vishal L

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0DEDF3B159719A448A49EF0E7B11E3223DA9DCE5@g01jpexmbkw24 \
    --to=qi.fuli@jp.fujitsu.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=msys.mizuma@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).