All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Fontenot <nafonten@amd.com>
To: Dave Jiang <dave.jiang@intel.com>, linux-cxl@vger.kernel.org
Cc: alison.schofield@intel.com, vishal.l.verma@intel.com,
	ira.weiny@intel.com, bwidawsk@kernel.org,
	dan.j.williams@intel.com
Subject: Re: [PATCH 6/7] ndctl: cxl: add logging functions for monitor
Date: Thu, 15 Sep 2022 10:55:49 -0500	[thread overview]
Message-ID: <40400223-a228-457a-e65f-61598dfa45c3@amd.com> (raw)
In-Reply-To: <166318850459.3087953.851045527272435004.stgit@djiang5-desk3.ch.intel.com>

On 9/14/22 15:48, Dave Jiang wrote:
> Duplicate log functions from ndctl/monitor to use for stdout and file
> logging.
> 
> Signed-off-by: Dave Jiang <dave.jiang@gmail.com>
> ---
>  cxl/monitor.c |   26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/cxl/monitor.c b/cxl/monitor.c
> index 2ab2e249f575..e030542a3fe8 100644
> --- a/cxl/monitor.c
> +++ b/cxl/monitor.c
> @@ -39,6 +39,32 @@ static struct monitor {
>  	bool human;
>  } monitor;
>  
> +static void log_standard(struct log_ctx *ctx, int priority, const char *file,
> +		int line, const char *fn, const char *format, va_list args)
> +{
> +	if (priority == 6)
> +		vfprintf(stdout, format, args);
> +	else
> +		vfprintf(stderr, format, args);
> +}
> +
> +static void log_file(struct log_ctx *ctx, int priority, const char *file,
> +		int line, const char *fn, const char *format, va_list args)
> +{
> +	FILE *f = monitor.log_file;
> +
> +	if (priority != LOG_NOTICE) {
> +		struct timespec ts;
> +
> +		clock_gettime(CLOCK_REALTIME, &ts);
> +		fprintf(f, "[%10ld.%09ld] [%d] ", ts.tv_sec, ts.tv_nsec, getpid());
> +		vfprintf(f, format, args);
> +	} else
> +		vfprintf(f, format, args);

The vfprintf() is always done here, you could just move it outside the if/else block.

-Nathan

> +
> +	fflush(f);
> +}
> +
>  static int monitor_event(struct cxl_ctx *ctx)
>  {
>  	int fd, epollfd, rc = 0, timeout = -1;
> 
> 

  reply	other threads:[~2022-09-15 15:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14 20:47 [PATCH 0/7] ndctl: cxl: add monitor support for trace events Dave Jiang
2022-09-14 20:47 ` [PATCH 1/7] ndctl: cxl: add helper function to parse trace event to json object Dave Jiang
2022-10-31 20:01   ` Alison Schofield
2022-10-31 21:37     ` Dave Jiang
2022-11-02 21:01       ` Ira Weiny
2022-09-14 20:48 ` [PATCH 2/7] ndctl: cxl: add helper to parse through all current events Dave Jiang
2022-10-31 20:05   ` Alison Schofield
2022-09-14 20:48 ` [PATCH 3/7] ndctl: cxl: add common function to enable event trace Dave Jiang
2022-09-14 20:48 ` [PATCH 4/7] ndctl: cxl: add common function to disable " Dave Jiang
2022-09-14 20:48 ` [PATCH 5/7] ndctl: cxl: add monitor function for event trace events Dave Jiang
2022-09-19 18:26   ` Alison Schofield
2022-09-14 20:48 ` [PATCH 6/7] ndctl: cxl: add logging functions for monitor Dave Jiang
2022-09-15 15:55   ` Nathan Fontenot [this message]
2022-09-15 16:02     ` Dave Jiang
2022-09-14 20:48 ` [PATCH 7/7] ndctl: cxl: add monitor command to cxl Dave Jiang
2022-09-14 22:19 ` [PATCH 0/7] ndctl: cxl: add monitor support for trace events Dave Jiang
2022-09-14 23:04   ` Verma, Vishal L
2022-09-22 14:21 ` Jonathan Cameron
2022-09-22 14:45   ` Dave Jiang

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=40400223-a228-457a-e65f-61598dfa45c3@amd.com \
    --to=nafonten@amd.com \
    --cc=alison.schofield@intel.com \
    --cc=bwidawsk@kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=vishal.l.verma@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.