File: stdlib.py

package info (click to toggle)
python-eliot 1.16.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 964 kB
  • sloc: python: 8,641; makefile: 151
file content (23 lines) | stat: -rw-r--r-- 590 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Integration with the standard library ``logging`` package."""

from logging import Handler

from ._action import log_message
from ._traceback import write_traceback


class EliotHandler(Handler):
    """A C{logging.Handler} that routes log messages to Eliot."""

    def emit(self, record):
        log_message(
            message_type="eliot:stdlib",
            log_level=record.levelname,
            logger=record.name,
            message=record.getMessage(),
        )
        if record.exc_info:
            write_traceback(exc_info=record.exc_info)


__all__ = ["EliotHandler"]