Re: [PATCH 01/11] string_list: print_string_list to use trace_printf
- From
Jeff King <peff@peff.net>
- Date
- Sep 6, 2018, 16:56 UTC
- Message-ID
- <20180906165602.GA19367@sigill.intra.peff.net>
- In-Reply-To
- <xmqqh8j236wj.fsf@gitster-ct.c.googlers.com>
On Thu, Sep 06, 2018 at 09:52:28AM -0700, Junio C Hamano wrote:
Show 8 quoted lines
> Stefan Beller <sbeller@google.com> writes: > > > It is a debugging aid, so it should print to the debugging channel. > > ... and rename it with trace_ prefix. > > Use of trace_printf() is nice, as we can control its behavior at > runtime ;-)
Yes, though...
Show 11 quoted lines
> > -void print_string_list(const struct string_list *p, const char *text)
> > +void trace_print_string_list(const struct string_list *p, const char *text)
> > {
> > int i;
> > if ( text )
> > - printf("%s\n", text);
> > + trace_printf("%s\n", text);
> > for (i = 0; i < p->nr; i++)
> > - printf("%s:%p\n", p->items[i].string, p->items[i].util);
> > + trace_printf("%s:%p\n", p->items[i].string, p->items[i].util);
> > }It seems funny that we'd iterate through the list checking over and over whether tracing is enabled.
Should this do:
if (!trace_want(&trace_default_key)) return;
at the top? (Or possibly even take a trace key from the caller, so that it can use whatever context makes sense for this particular list?)
-Peff