Passed
Push — dependabot/pip/scikit-learn-1.... ( c9cd46...4f3797 )
by
unknown
04:03 queued 01:57
created

mandos.model.utils.setup.MandosLogging.set_main_level()   A

Complexity

Conditions 4

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 10
nop 3
dl 0
loc 13
rs 9.9
c 0
b 0
f 0
1
from __future__ import annotations
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
from loguru import logger
0 ignored issues
show
introduced by
Unable to import 'loguru'
Loading history...
3
4
# noinspection PyProtectedMember
5
from loguru._logger import Logger
0 ignored issues
show
introduced by
Unable to import 'loguru._logger'
Loading history...
6
7
from mandos.model.utils.fancy_logger import FancyLoguru, HandlerInfo, Defaults
8
9
10
def _notice(__message: str, *args, **kwargs):
11
    return logger.log("NOTICE", __message, *args, **kwargs)
12
13
14
def _caution(__message: str, *args, **kwargs):
15
    return logger.log("CAUTION", __message, *args, **kwargs)
16
17
18
class MyLogger(Logger):
19
    """
20
    A wrapper that has a fake notice() method to trick static analysis.
21
    """
22
23
    def notice(self, __message: str, *args, **kwargs):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
24
        raise NotImplementedError()  # not real
25
26
    def caution(self, __message: str, *args, **kwargs):
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
27
        raise NotImplementedError()  # not real
28
29
30
# WEIRD AS HELL, but it works
31
# noinspection PyTypeChecker
32
logger: MyLogger = logger
33
logger.notice = _notice
34
logger.caution = _caution
35
MANDOS_SETUP = FancyLoguru(logger).config_levels()
36
37
38
__all__ = ["logger", "MANDOS_SETUP", "FancyLoguru", "HandlerInfo", "Defaults"]
39