in reply to Error-checking and logging

While I generally agree with you on the importance of logging, I have a couple of comments:

A minor one first:

Built-in functions. How many times have you seen someone write: open HANDLE, ">myfile"; What if there is no space on the drive? The program will crash the first time HANDLE is written to, cause it wasn't opened successfully.

The problem is not usually a lack of space on the disk, 99% of the time it is with user rights: the file you want to write already exists and is owned by someone else.

Then something a little more philosophical:

As for logging ... it's usually the only way you know what your program has done. When I write something, it spews out tons of crap onto the screen. 99% of it, I will never use. 99% of the time, I won't use the other 1%. That 1% of the time ... My! how that 1% of the logging has saved me days of work.

I don't know about that. Code that fills the screen with useless log/warning info is just likely to make you miss the one message that was really important and that should have gotten your attention. Instead it got lost in the flow of usual crap that your program generates. So unless I can also provide the user with tools to filter the output, I usually stick to outputting only the most important warnings, while providing ways to generate additional logging if need be.

Replies are listed 'Best First'.
Re: Re: Error-checking and logging
by dragonchild (Archbishop) on Feb 26, 2002 at 16:55 UTC
    Logs, in general, should never be seen by the user. I'm referring more to development and run-time logs. Things like the httpd log. Of course, we may be talking around each other due to semantic differences.

    Sometimes, when I'm writing up logging capability, I'll have certain messages go to one log, which would be the error log. I'll also have more detailed information go to another log. Then, I can read a small log to find that a problem occurred. Using timestamps, I can find out where in the other log the error is, then find out what occurred.

    *shrugs* Different folks, different strokes. Whatever works.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Re: Re: Error-checking and logging
by grep (Monsignor) on Feb 26, 2002 at 18:13 UTC
    my $.02

    Actually I prefer:

    Log it all and let grep sort it out ;)

    Seriously I find the more info I log the better (or faster) the troubleshooting is. Tools like grep and sort are there for that reason, so is cheap disk space. As dragonchild points out log files are for admins and programmers not users.

    grep
    grep> grep clue /home/users/*