Package lxml :: Module etree :: Class PyErrorLog |
[hide private]
[frames] | no frames]

# Class PyErrorLog

       object --+
                |
    _BaseErrorLog --+
                    |
                   PyErrorLog

PyErrorLog(self, logger_name=None, logger=None) A global error log that connects to the Python stdlib logging package.

The constructor accepts an optional logger name or a readily instantiated logger instance.

If you want to change the mapping between libxml2's ErrorLevels and Python logging levels, you can modify the level_map dictionary from a subclass.

The default mapping is:

    ErrorLevels.WARNING = logging.WARNING
    ErrorLevels.ERROR   = logging.ERROR
    ErrorLevels.FATAL   = logging.CRITICAL

You can also override the method `receive()` that takes a LogEntry object and calls `self.log(log_entry, format_string, arg1, arg2, ...)` with appropriate data.

Instance Methods | [hide private]
__init__(self, logger_name=None, logger=None) x.__init__(...) initializes x; see help(type(x)) for signature |
a new object with type S, a subtype of T |
__new__(T, S, ...) |
copy(...) Dummy method that returns an empty error log. |
log(self, log_entry, message, *args) Called by the .receive() method to log a _LogEntry instance to the Python logging system. This handles the error level mapping. |
receive(self, log_entry) Receive a _LogEntry instance from the logging system. Calls the .log() method with appropriate parameters: |
Inherited from `_BaseErrorLog`: `__repr__` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties | [hide private]
| level_map
Inherited from `_BaseErrorLog`: `last_error` Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, logger_name=None, logger=None) (Constructor) |
x.__init__(...) initializes x; see help(type(x)) for signature Overrides: object.__init__

### __new__(T, S, ...) |
Returns: a new object with type S, a subtype of T Overrides: object.__new__

### copy(...) |
Dummy method that returns an empty error log. Overrides: _BaseErrorLog.copy

### log(self, log_entry, message, *args) |
Called by the .receive() method to log a _LogEntry instance to the Python logging system. This handles the error level mapping. In the default implementation, the `message` argument receives a complete log line, and there are no further `args`. To change the message format, it is best to override the .receive() method instead of this one.

### receive(self, log_entry) |
Receive a _LogEntry instance from the logging system. Calls the .log() method with appropriate parameters:
    self.log(log_entry, repr(log_entry))
You can override this method to provide your own log output format. Overrides: _BaseErrorLog.receive