[AD] configurable logging |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
I find our log files a bit hard to read lately with all the GL
extensions and X11 keyboard codes in it. At the same time, I think we
log way too few things yet to properly debug some problems. Therefore I
think we should have somewhat more advanced logging. I found the way it
works in Wine is very simple yet can provide really detailed information
when needed for hard to track bug reports, so I modeled the following
proposal after how they do it.
The first thing would be a way to select what you are interested in, for
us this should be via allegro.cfg:
[trace]
channels=all
level=info
timestamps=0
lines=0
The channels key tells which channels to log, default would be all, can
set to none to disable logging, or else a comma separated list of
system, display, keyboard, x11, font,... each source file or addon can
define their own channels if they want.
The level key specifies how verbosely to log:
error: Only errors are logged.
warn: The above, plus also warnings.
info: Above, plus important info. About what we have right now.
debug: Detailed tracing. E.g. things like loading a bitmap
successfully - this would be off by default, but we might
want to ask for it in hard to reproduce bug reports.
With "timestamps" could select whether to prepend log messages with a
timestamp. It will make it easy to spot badly written parts in our
startup/shutdown code - off by default.
And finally whether to prepend log messages with file:linenumber, just
because I like to find things faster - but off by default.
The use inside the source code would not change much from how it is
currently, except the somewhat cumbersome PREFIX_* definitions would not
exist any longer. At the beginning of each source file, we would instead
have something like:
ALLEGRO_DEBUG_CHANNEL("display")
And TRACE would be split into four functions:
ALLEGRO_ERROR("No display can be created.\n");
ALLEGRO_WARN("Selected format %s not usable by Allegro.\n", format);
ALLEGRO_INFO("Choosing visual %d.\n", i);
ALLEGRO_TRACE("OpenGL extension %s loaded successfully.\n", name);
--
Elias Pschernig <elias@xxxxxxxxxx>