Balsa's terminal logging
Albrecht Dreß <[email protected]>
| Newsgroups | gmane.comp.gnome.apps.balsa |
|---|---|
| Message-ID | <[email protected]> |
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). 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. 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. _______________________________________________ balsa-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/balsa-list
signature.asc
(application/pgp-signature, 473 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAABCAAGBQJaT5msAAoJEEypbw5n59n4hYEH/3fgZKwJXBAWAfG8QOBEzmuv fn6Kr7AkEtaPMqbcI0g7ToNZe/xQw3sd7olhgNB/kRzzjQAGdmclTl/8t7QRuLTR tmFqvADU9olJMsYfIssLhaQj4bf07GXYXC7j3e26N7e/8diuFSNtQY7uUPyK+uXN UOA6j9gcHZ5oWQEzH3GfMxNoBpm35v+aGAytVgNtjgfqwjczW+KgNInSAXe2WDOr 29P8i2cOvVhxwRAEbXZ+KcJCXWRKp6ZtF5mWHA3fyQeL8dkfr4bwYTXA7316jemi wjzPaIJ/FviMEuiVlGq/ksQYOXbBAbyainBc0erWnAiGl+cySF8KZfmfnOKjiIU= =or08 -----END PGP SIGNATURE-----