ebook_homebrew.utils.logging   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 27
dl 0
loc 42
ccs 26
cts 26
cp 1
rs 10
c 0
b 0
f 0
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A AppLog.info() 0 2 1
A AppLog.warn() 0 2 1
A AppLog.critical() 0 2 1
A AppLog.error() 0 2 1
A AppLog.exception() 0 2 1
A AppLog.debug() 0 2 1
A AppLog.__init__() 0 2 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A get_logger() 0 2 1
1 1
import os
2 1
import logging
3 1
from logging import config
4 1
import yaml
5
6 1
yaml_path = os.path.join(os.path.dirname(__file__), "logging.yaml")
7
8 1
with open(yaml_path) as f:
9 1
    dict_config = yaml.load(f, Loader=yaml.FullLoader)
10
11 1
config.dictConfig(dict_config)
12
13
14 1
class AppLog:
15
16 1
    logger = None
17
18 1
    def __init__(self, name):
19 1
        self.logger = logging.getLogger(name)
20
21 1
    def debug(self, msg, *args, **kwargs):
22 1
        self.logger.debug(msg, *args, **kwargs)
23
24 1
    def info(self, msg, *args, **kwargs):
25 1
        self.logger.info(msg, *args, **kwargs)
26
27 1
    def warn(self, msg, *args, **kwargs):
28 1
        self.logger.warning(msg, *args, **kwargs)
29
30 1
    def error(self, msg, *args, **kwargs):
31 1
        self.logger.error(msg, *args, **kwargs)
32
33 1
    def exception(self, msg, *args, **kwargs):
34 1
        self.logger.exception(msg, *args, **kwargs)
35
36 1
    def critical(self, msg, *args, **kwargs):
37 1
        self.logger.critical(msg, *args, **kwargs)
38
39
40 1
def get_logger(name):
41
    return AppLog(name)
42