Re: Balsa's terminal logging
- From: Peter Bloomfield <PeterBloomfield bellsouth net>
- To: balsa-list gnome org
- Subject: Re: Balsa's terminal logging
- Date: Fri, 05 Jan 2018 23:26:31 -0500
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Albrecht:
On 01/05/2018 10:28:44 AM Fri, Albrecht Dreß wrote:
Hi all,
I noticed that Balsa uses a variety of methods to print messages typically used for error reporting or for
/very/ low-level debugging to the terminal (note: *not* via libbalsa_information):
* fprintf(stderr, …), sometimes depending on balsa_app.debug
* printf(…), sometimes depending on balsa_app.debug
* g_print(…), sometimes depending on balsa_app.debug (prints to stdout)
* g_printerr(…) (prints to stderr)
* g_debug (prints to stdout)
* g_error (prints to stderr)
* g_message (ditto)
* g_warning (ditto)
This is somewhat confusing, clutters up the xsession log files, and is not always helpful for real debugging,
as it lacks timing and thread information (e.g. g_debug() output from parallel POP3 or SMTP operations in
different threads).
Agreed! Organization of these messages is long overdue :-)
My idea is to write our own g_log default handler, which includes all this extra information, and
/exclusively/ use g_log(…) and the related convenience macros to emit any information. The output could look
like
2018-01-05T14:55:42.161399Z balsa:(main) WARNING[libbalsa]: some message from libbalsa
2018-01-05T14:55:42.161414Z balsa:4008e0 ERROR[default]: error message from thread 0x4008e0
iso8601 time stamp thread level[domain]
I'm not sure if the domain is of any use (probably not), so we could just omit it.
If that is the domain that is selected in G_MESSAGES_DEBUG, I feel that we should start using it. Running Balsa with
"G_MESSAGES_DEBUG=all" sometimes spews messages from many other uninteresting domains!
Our log handler should evaluate the balsa_app.debug setting and the G_MESSAGES_DEBUG environment variable:
* levels ERROR, CRITICAL, WARNING, MESSAGE: always print to stderr
* level INFO: print to stdout only if balsa_app.debug is TRUE, and maybe G_MESSAGES_DEBUG is defined
* level DEBUG: print to stdout only if G_MESSAGES_DEBUG is defined
The calls to [f]printf, g_print and g_printerr need to be converted to the appropriate macros:
* fprintf 🠆 g_info() for balsa_app.debug, g_warning() or g_error() otherwise
* printf and g_print 🠆 g_info() for balsa_app.debug, g_message() otherwise
* g_printerr 🠆 g_warning() or g_error()
What do you think about this idea? As always, any comment is welcome!
Cheers,
Albrecht.
It looks like a very useful discipline to me.
Best,
Peter
-----BEGIN PGP SIGNATURE-----
iF0EARECAB0WIQS030wPRfNNA5alz3MfX9S1uSp09QUCWlBP9wAKCRAfX9S1uSp0
9WgSAJ9gdFe5BfvBJ1Uu6BEIjcyEQzEYzQCfYHLT6nJ4qcRxXTXqaG6XXwOanJk=
=tRWu
-----END PGP SIGNATURE-----
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]