1
|
|
|
"""Replicates some of the `logging.Logger` API.""" |
2
|
|
|
|
3
|
|
|
import logging |
4
|
|
|
import sys |
5
|
|
|
|
6
|
|
|
from . import utils |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
__all__ = ['log', 'debug', 'info', 'warning', 'error', 'critical', 'exception'] |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
def log(level, message, *args, **kwargs): |
13
|
|
|
utils.create_logger_record(level, message, *args, **kwargs) |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
def debug(message, *args, **kwargs): |
17
|
|
|
log(logging.DEBUG, message, *args, **kwargs) |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
def info(message, *args, **kwargs): |
21
|
|
|
log(logging.INFO, message, *args, **kwargs) |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
def warning(message, *args, **kwargs): |
25
|
|
|
log(logging.WARNING, message, *args, **kwargs) |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
def error(message, *args, **kwargs): |
29
|
|
|
log(logging.ERROR, message, *args, **kwargs) |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
def critical(message, *args, **kwargs): |
33
|
|
|
log(logging.CRITICAL, message, *args, **kwargs) |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
def exception(message, *args, **kwargs): |
37
|
|
|
kwargs['exc_info'] = kwargs.get('exc_info', sys.exc_info()) |
38
|
|
|
log(logging.ERROR, message, *args, **kwargs) |
39
|
|
|
|