Too Many if Statements?
Kent Johnson
kent at kentsjohnson.com
Fri Feb 10 09:49:56 EST 2006
slogging_away wrote:
> bruno at modulix wrote:
>>Why storing error messages ? Why don't you just write'em out (be it to
>>stdout or to a file) ?
>
>
> I guess I could do that, (write them to a file as they are discovered).
> Right now the error messages are stored in the array and then the the
> array is scanned via, a for loop and the error messages are written to
> several files in different formats based on the severity of the errors,
> (on a per device basis, a per severity basis, etc.). This keeps the
> write statements to a minimum and in a central location of the script
> instead of having several statements for each individual error message
> spread throughout the script, (three write statements per error message
> at over 500 error messages would be a significant change).
Sounds like you might like the logging module. A single log entry can be
written to multiple destinations based on level or source of the entry.
The distribution of log entries is controlled by the logging
configuration which can be stored in a text file if you like.
Kent
More information about the Python-list
mailing list