File: __init__.py

package info (click to toggle)
sen 0.6.0-0.1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 492 kB
  • sloc: python: 5,445; makefile: 9
file content (22 lines) | stat: -rw-r--r-- 695 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import logging

from sen.constants import FALLBACK_LOG_PATH

__version__ = "0.6.0"


def set_logging(name="sen", level=logging.DEBUG, path=FALLBACK_LOG_PATH):
    logger = logging.getLogger(name)
    # do not propagate logs from logger 'sen' to root logger (as they could be accidentally
    # displayed in terminal)
    logger.propagate = False
    logger.setLevel(level)

    handler = logging.FileHandler(path)
    handler.setLevel(logging.DEBUG)
    # handler = logging.StreamHandler(sys.stderr)

    formatter = logging.Formatter(
        '%(asctime)s.%(msecs).03d %(filename)-17s %(levelname)-6s %(message)s', '%H:%M:%S')
    handler.setFormatter(formatter)
    logger.addHandler(handler)