class Reporter: (source)
Info/warning/error reporter and ``system_message`` element generator. Five levels of system messages are defined, along with corresponding methods: `debug()`, `info()`, `warning()`, `error()`, and `severe()`. There is typically one Reporter object per process. A Reporter object is instantiated with thresholds for reporting (generating warnings) and halting processing (raising exceptions), a switch to turn debug output on or off, and an I/O stream for warnings. These are stored as instance attributes. When a system message is generated, its level is compared to the stored thresholds, and a warning or error is generated as appropriate. Debug messages are produced if the stored debug switch is on, independently of other thresholds. Message output is sent to the stored warning stream if not set to ''. The Reporter class also employs a modified form of the "Observer" pattern [GoF95]_ to track system messages generated. The `attach_observer` method should be called before parsing, with a bound method or function which accepts system messages. The observer can be removed with `detach_observer`, and another added in its place. .. [GoF95] Gamma, Helm, Johnson, Vlissides. *Design Patterns: Elements of Reusable Object-Oriented Software*. Addison-Wesley, Reading, MA, USA, 1995.
Method | __init__ |
:Parameters: - `source`: The path to or description of the source data. - `report_level`: The level at or above which warning output will be sent to `stream`. - `halt_level`: The level at or above which `SystemMessage` exceptions will be raised, halting execution... |
Method | attach |
The `observer` parameter is a function or bound method which takes one argument, a `nodes.system_message` instance. |
Method | debug |
Level-0, "DEBUG": an internal reporting issue. Typically, there is no effect on the processing. Level-0 system messages are handled separately from the others. |
Method | detach |
Undocumented |
Method | error |
Level-3, "ERROR": an error that should be addressed. If ignored, the output will contain errors. |
Method | info |
Level-1, "INFO": a minor issue that can be ignored. Typically there is no effect on processing, and level-1 system messages are not reported. |
Method | notify |
Undocumented |
Method | set |
Undocumented |
Method | severe |
Level-4, "SEVERE": a severe error that must be addressed. If ignored, the output will contain severe errors. Typically level-4 system messages are turned into exceptions which halt processing. |
Method | system |
Return a system_message object. |
Method | warning |
Level-2, "WARNING": an issue that should be addressed. If ignored, there may be unpredictable problems with the output. |
Constant | DEBUG |
Undocumented |
Constant | ERROR |
Undocumented |
Constant | INFO |
Undocumented |
Constant | SEVERE |
Undocumented |
Constant | WARNING |
Undocumented |
Class Variable | levels |
List of names for system message levels, indexed by level. |
Instance Variable | debug |
Show debug (level=0) system messages? |
Instance Variable | encoding |
The output character encoding. |
Instance Variable | error |
The character encoding error handler. |
Instance Variable | halt |
The level at or above which `SystemMessage` exceptions will be raised, halting execution. |
Instance Variable | max |
The highest level system message generated so far. |
Instance Variable | observers |
List of bound methods or functions to call with each system_message created. |
Instance Variable | report |
The level at or above which warning output will be sent to `self.stream`. |
Instance Variable | source |
The path to or description of the source data. |
Instance Variable | stream |
Where warning output is sent. |
:Parameters: - `source`: The path to or description of the source data. - `report_level`: The level at or above which warning output will be sent to `stream`. - `halt_level`: The level at or above which `SystemMessage` exceptions will be raised, halting execution. - `debug`: Show debug (level=0) system messages? - `stream`: Where warning output is sent. Can be file-like (has a ``.write`` method), a string (file name, opened for writing), '' (empty string) or `False` (for discarding all stream messages) or `None` (implies `sys.stderr`; default). - `encoding`: The output encoding. - `error_handler`: The error handler for stderr output encoding.
The `observer` parameter is a function or bound method which takes one argument, a `nodes.system_message` instance.
Level-0, "DEBUG": an internal reporting issue. Typically, there is no effect on the processing. Level-0 system messages are handled separately from the others.
Level-1, "INFO": a minor issue that can be ignored. Typically there is no effect on processing, and level-1 system messages are not reported.
Level-4, "SEVERE": a severe error that must be addressed. If ignored, the output will contain severe errors. Typically level-4 system messages are turned into exceptions which halt processing.
Level-2, "WARNING": an issue that should be addressed. If ignored, there may be unpredictable problems with the output.
The level at or above which `SystemMessage` exceptions will be raised, halting execution.