File: logger.py

package info (click to toggle)
dblatex 0.3.12py3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 12,684 kB
  • sloc: xml: 102,889; python: 8,259; makefile: 119; sh: 48
file content (21 lines) | stat: -rw-r--r-- 529 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import logging

VERBOSE = 1
NORMAL = 0
LESS_VERBOSE = -1
QUIET = -2

def logger(logname, level):
    loglevels = { QUIET:        logging.ERROR-1,
                  LESS_VERBOSE: logging.WARNING-1,
                  NORMAL:       logging.INFO-1,
                  VERBOSE:      logging.DEBUG-1 }

    log = logging.getLogger(logname)
    log.setLevel(loglevels[level])
    console = logging.StreamHandler()
    format = logging.Formatter("%(message)s")
    console.setFormatter(format)
    log.addHandler(console)
    return log