pdf-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pdf-devel] Logging function


From: Aleksander Morgado
Subject: Re: [pdf-devel] Logging function
Date: Tue, 19 Feb 2008 10:12:50 +0100
User-agent: Thunderbird 2.0.0.9 (Macintosh/20071031)

Hi!

I am thinking in preparing a simple logging function to be used mostly
for development and debugging purposes. It would allow to enable at
configure level not only the level of debug wanted, but also which
modules should have the logging enabled.

Don't spend too much time on a logging function; it has been done so
many times in the past.  For most purposes, printing debug information
to stderr is good enough.  The only exceptions I can think of to using
just plain stderr are:
1. you write a daemon, in which case messages (only very important
ones) should go to the system logger.
2. you have a multithreaded program and have concurrency issues;
in such a case a logger with a high-res timestamp and locking can be
useful.

Well, my proposed approach was in fact dumping the logs to stdout/stderr. I was never thinking in really creating a program log, and it wouldn't be more than 50-60 LOC, including changes in configure.ac


After 20 years of programming, I can say that log files in general really
are not very useful for debugging.  If you think a lot about something
before writing a message, you will find you have very few actually
useful messages.  What would be far more useful than debug messages
are test scripts using whatever scripting language you like and your
favorite debugger (gdb).  Input for testing various things (overflows, etc)
is also useful - this usually requires quite a bit of skill since the test input
is often generated by hand or with a small purpose-built program.

The idea is to have that logs to help the development process, not for any other purpose, so not really as an output for a user. The unit tests that you talk about are already being prepared in the Torture Chamber.


Just as a small example of why logs are not really useful - let's say the
program hangs.  Some people would say "Oh, I'll make a function
tracer".  Well, you may have a few hundred MB to go through in your
function tracer's log as opposed to maybe only 4MB for a core file; in
addition to that, who knows if you will actually log the call which hung.
When the program appears to hang, the best thing to do is attach a
debugger and then you see the last few function calls and can actually
inspect variables.

In any case the logs are a replacement to the debugger. IMHO, they are different tools for different things, like for example Valgrind and GDB. The log approach would help not only to the developer which is creating the module, but also to anyone interested in having a fast insight of what the single module is doing and how it is behaving (only enabling logs of that specific module, for example). In a standard compilation these logs wouldn't be dumped, so I don't really see any big problem in it.


- Aleksander






reply via email to

[Prev in Thread] Current Thread [Next in Thread]