All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Teng Long <dyroneteng@gmail.com>
Cc: avarab@gmail.com, git@jeffhostetler.com, git@vger.kernel.org,
	tenglong.tl@alibaba-inc.com
Subject: Re: [PATCH v2 2/2] tr2: shows scope unconditionally in addition to key-value pair
Date: Fri, 12 Aug 2022 14:16:57 -0700	[thread overview]
Message-ID: <xmqqo7wp9n7a.fsf@gitster.g> (raw)
In-Reply-To: <9856058df68d61557b11dc2fc7179acae24f5d8e.1660272404.git.dyroneteng@gmail.com> (Teng Long's message of "Fri, 12 Aug 2022 10:56:46 +0800")

Teng Long <dyroneteng@gmail.com> writes:

> diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c
> index c5c8cfbbaa..37a3163be1 100644
> --- a/trace2/tr2_tgt_event.c
> +++ b/trace2/tr2_tgt_event.c
> @@ -479,9 +479,12 @@ static void fn_param_fl(const char *file, int line, const char *param,
>  {
>  	const char *event_name = "def_param";
>  	struct json_writer jw = JSON_WRITER_INIT;
> +	enum config_scope scope = current_config_scope();
> +	const char *scope_name = config_scope_name(scope);
>  
>  	jw_object_begin(&jw, 0);
>  	event_fmt_prepare(event_name, file, line, NULL, &jw);
> +	jw_object_string(&jw, "scope", scope_name);
>  	jw_object_string(&jw, "param", param);
>  	jw_object_string(&jw, "value", value);
>  	jw_end(&jw);

OK, that is quite straight-forward.

> diff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c
> index c42fbade7f..69f8033077 100644
> --- a/trace2/tr2_tgt_normal.c
> +++ b/trace2/tr2_tgt_normal.c
> @@ -298,8 +298,11 @@ static void fn_param_fl(const char *file, int line, const char *param,
>  			const char *value)
>  {
>  	struct strbuf buf_payload = STRBUF_INIT;
> +	enum config_scope scope = current_config_scope();
> +	const char *scope_name = config_scope_name(scope);
>  
> -	strbuf_addf(&buf_payload, "def_param %s=%s", param, value);
> +	strbuf_addf(&buf_payload, "def_param scope:%s %s=%s", scope_name, param,
> +		    value);
>  	normal_io_write_fl(file, line, &buf_payload);
>  	strbuf_release(&buf_payload);
>  }

So is this one.  Quite nice.

Is everybody happy with the choice of ":" colon here, though?  The
one in tgt_perf below uses the same delimiter that is used between
<param, value> to delimit <"scope", scome_name>.  I am wondering if
this one should use "=", the delimiter used between <param, value>
in this output stream, to match.  I do not care at all either way,
but I am mentioning it because I happened have noticed it, and
because somebody else may care.

Thanks, will queue.


> diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c
> index a1eff8bea3..8cb792488c 100644
> --- a/trace2/tr2_tgt_perf.c
> +++ b/trace2/tr2_tgt_perf.c
> @@ -441,12 +441,17 @@ static void fn_param_fl(const char *file, int line, const char *param,
>  {
>  	const char *event_name = "def_param";
>  	struct strbuf buf_payload = STRBUF_INIT;
> +	struct strbuf scope_payload = STRBUF_INIT;
> +	enum config_scope scope = current_config_scope();
> +	const char *scope_name = config_scope_name(scope);
>  
>  	strbuf_addf(&buf_payload, "%s:%s", param, value);
> +	strbuf_addf(&scope_payload, "%s:%s", "scope", scope_name);
>  
> -	perf_io_write_fl(file, line, event_name, NULL, NULL, NULL, NULL,
> -			 &buf_payload);
> +	perf_io_write_fl(file, line, event_name, NULL, NULL, NULL,
> +			 scope_payload.buf, &buf_payload);
>  	strbuf_release(&buf_payload);
> +	strbuf_release(&scope_payload);
>  }
>  
>  static void fn_repo_fl(const char *file, int line,

  reply	other threads:[~2022-08-12 21:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-21 13:27 [PATCH 0/2] tr2: shows the scope unconditionally with config tenglong.tl
2022-07-21 13:27 ` [PATCH 1/2] api-trace2.txt: print config key-value pair tenglong.tl
2022-07-21 13:27 ` [PATCH 2/2] tr2: shows scope unconditionally in addition to " tenglong.tl
2022-07-21 16:57   ` Junio C Hamano
2022-07-22  6:12     ` tenglong.tl
2022-07-22  8:19 ` [PATCH v1 0/2] tr2: shows the scope unconditionally with config tenglong.tl
2022-07-22  8:19   ` [PATCH v1 1/2] api-trace2.txt: print config key-value pair tenglong.tl
2022-07-22 10:59     ` Ævar Arnfjörð Bjarmason
2022-07-25 19:07       ` Junio C Hamano
2022-08-01 12:25       ` tenglong.tl
2022-08-05 22:21         ` Junio C Hamano
2022-08-08  6:16           ` Teng Long
2022-07-22 21:05     ` Junio C Hamano
2022-07-23  6:06       ` tenglong.tl
2022-07-23 17:47         ` Junio C Hamano
2022-07-25  9:18           ` tenglong.tl
2022-07-22  8:19   ` [PATCH v1 2/2] tr2: shows scope unconditionally in addition to " tenglong.tl
2022-08-12  2:56   ` [PATCH v2 0/2] tr2: shows the scope unconditionally with config Teng Long
2022-08-12  2:56     ` [PATCH v2 1/2] api-trace2.txt: print config key-value pair Teng Long
2022-08-12  2:56     ` [PATCH v2 2/2] tr2: shows scope unconditionally in addition to " Teng Long
2022-08-12 21:16       ` Junio C Hamano [this message]
2022-08-19 21:18     ` [PATCH v2 0/2] tr2: shows the scope unconditionally with config Junio C Hamano

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=xmqqo7wp9n7a.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=dyroneteng@gmail.com \
    --cc=git@jeffhostetler.com \
    --cc=git@vger.kernel.org \
    --cc=tenglong.tl@alibaba-inc.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.