Re: Logging Best Practice?
- From: "Arthur J. O'Dwyer" <ajo@xxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 29 Dec 2005 14:46:29 -0500 (EST)
On Thu, 29 Dec 2005, Jeffery wrote:
This might seem like a trivial point, but I'm curious what others are doing regarding logging before an event or after an event, in general. Here is a pseudo-code example:
<code>
some_action_B
if (return_code == good)
log "Some action B succeeded."
else {
log "Some action B failed."
do_failure_logic
}
</code>
This is good feedback for the user (read: admin), in case something goes mildly wrong and he needs to read the log to find out the first stage at
which a problem was detected. "Oops, action B failed! I guess I'd better
go look at B-dot-config..."
<code> log "Performing action Y." some_action_Y </code>
This is the easiest way to debug a broken program. If the programmer sees "Performing action Y..." followed by a crash, he can be pretty sure the error is somewhere in the code for action Y. As you pointed out, trying to print this message /after/ action Y is completed doesn't really help the debugging programmer.
Programs that aren't broken don't need this kind of logging, I suppose. On the other hand, it's a courtesy to the guy who'll come after you and break the program anyway. :)
Bottom line: What's the purpose of your logging code? Is it to help the user understand what happened, later on; or is it to help yourself fix a broken program right now?
-Arthur .
- Follow-Ups:
- Re: Logging Best Practice?
- From: Jeffery
- Re: Logging Best Practice?
- References:
- Logging Best Practice?
- From: Jeffery
- Logging Best Practice?
- Prev by Date: Re: Logging Best Practice?
- Next by Date: Re: Logging Best Practice?
- Previous by thread: Re: Logging Best Practice?
- Next by thread: Re: Logging Best Practice?
- Index(es):
Relevant Pages
|