Error Log for P1tr

Registered by Chris Ortner

P1tr needs a way to write messages to an error log. It should be available for use in all P1tr modules, support different log levels and should write to a file.

Blueprint information

Status:
Started
Approver:
None
Priority:
High
Drafter:
None
Direction:
Needs approval
Assignee:
Chris Ortner
Definition:
Approved
Series goal:
Accepted for 0.1
Implementation:
Beta Available
Milestone target:
milestone icon beta
Started by
Chris Ortner

Related branches

Sprints

Whiteboard

Implemented in revision 78.
In every module where you want to use error logging, add such a line:
from lib.logger import log
Now you can use the log function to write to a logfile in log/error.log or to terminal. Example:
log('i', 'Welcome to the middle of the P1tr run!')
The first argument specifies the kind of message. These are available:
f: fatal errors, use only if P1tr has to shut down or something equally terrible happens
e: normal errors for everyday use
w: warnings, things that don't threaten the P1tr run at all, but should be taken care of by the user nevertheless
i: informations, pure status messages or something like that. You can use this for debugging.
Tracebacks of exceptions get printed as well.
All information gets written to the error log file.
The amount of stuff shown on the terminal depends on the loglevel, which is currently set in lib/logger.py:60. For setting it use the same letters as you use for the log function. Now you use them to specify the lowest kind of error message which is shown on the terminal. Additionally you can use 'n' here, which avoids all terminal output.

Great! I was in need of this for quite a while now.
m-otteneder

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.