bot.utils.logger   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 3

1 Function

Rating   Name   Duplication   Size   Complexity  
A make_logger() 0 26 3
1
"""Makes the logger for the program"""
2
import logging
3
4
5
def make_logger(name: str, log_level: str) -> logging.Logger:
6
    """Make Logger
7
8
    Creates the logger that is used by the bot. The data handler makes it own log
9
10
    :param name: Name of logger
11
    :type name: str
12
    :param log_level: Logging level. Valid strings are 'DEBUG', 'INFO', 'WARNING',
13
            'ERROR', 'CRITICAL'
14
    :type log_level: st
15
    :return: Logger class that handled the logging.
16
    :rtype: logging.Logger
17
    """
18
    discord_logger = logging.getLogger("discord")
19
    this_logger = logging.getLogger(name)
20
    for logger in [discord_logger, this_logger]:
21
        logger.setLevel(log_level)
22
        formatter = logging.Formatter(
23
            "%(levelname)s - %(name)s - %(asctime)s - %(message)s", "%Y-%m-%d %H:%M:%S"
24
        )
25
        ch = logging.StreamHandler()
26
        ch.setFormatter(formatter)
27
        logger.addHandler(ch)
28
    if log_level == "DEBUG":
29
        discord_logger.setLevel("INFO")
30
    return logger
0 ignored issues
show
introduced by
The variable logger does not seem to be defined in case the for loop on line 20 is not entered. Are you sure this can never be the case?
Loading history...
31