Calls to ch_log() left in released code

21 views
Skip to first unread message

Gary Johnson

unread,
Jun 1, 2024, 10:12:09 PM6/1/24
to vim...@googlegroups.com
I would like to request that developers not leave calls to ch_log()
enabled in released code, that is, in code that has been committed
to the GitHub repo.

I just tried debugging some Vim code by sprinkling calls to ch_log()
in it. When I ran tail on the log file, I was inundated with log
messages from other sources, making it hard to find mine. To quiet
the log, I put #if 0/#endif around several calls in

channel.c
evalfunc.c
main.c
ops.c
os_unix.c
ui.c

It would be nice if the responsible developers would fix those in
the manner they prefer, since the project doesn't seem to have
a uniform solution for this, such as the one used in term.c.

Perhaps a note about not leaving calls to ch_log() enabled when
you're done debugging should be added to src/README.md.

Regards,
Gary

Christian Brabandt

unread,
Jun 2, 2024, 10:55:22 AM6/2/24
to vim...@googlegroups.com
I thought the idea was that you can use `--log file` and have a log with
all kind of information that can be used even with released versions of
Vim. So I have used it e.g. to debug what keys are received by Vim when
a user complains certain keys don't work in alacritty or kitty terminal.

If we disable the calls to ch_log() we wouldn't be able to debug those,
no?

Thanks,
Christian
--
I believe that the moment is near when by a procedure of active paranoiac
thought, it will be possible to systematize confusion and contribute to the
total discrediting of the world of reality.
-- Salvador Dali

Gary Johnson

unread,
Jun 2, 2024, 3:05:41 PM6/2/24
to vim...@googlegroups.com
True, but the log can become so noisy as to be useless for debugging
any other problem. It seems we have two conflicting needs.

What I've seen on other projects is for there to be groups of debug
print statements, with each group assigned one of 32 bits. These
were enabled at compile time for debugging in the lab rather than in
the field, but it could be done at run time, either as
a command-line argument or a function call. Such groups could be
given names instead of bits to make the UI friendlier and more
extensible.

Another, simpler approach would be to add a global, compile-time
macro that would be enabled for releases, but could be disabled by
a developer to quiet all those terminal-related calls to ch_log().
That would allow a developer wanting to use ch_log() for their own
purposes to simply add something like -DNOTERMDEBUG or -UTERMDEBUG
to the CFLAGS in their environment.

Regards,
Gary

Reply all
Reply to author
Forward
0 new messages