mongomantic.config.CleanFormatter.format()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nop 2
1
import logging
2
import os
3
4
__all__ = ["MongoSettings", "logger"]
5
6
7
class MongoSettings:
8
    uri: str = os.getenv("MONGO_URI", "mongodb://localhost:27017")
9
    database: str = os.getenv("MONGO_DATABASE", "test")
10
11
12
class CleanFormatter(logging.Formatter):
13
    """Logging Formatter without colors"""
14
15
    fmt = "%(levelname)s:     %(message)s (%(filename)s:%(lineno)d) <%(funcName)s> @ %(asctime)s"
16
17
    def format(self, record):
18
        formatter = logging.Formatter(self.fmt)
19
        return formatter.format(record)
20
21
22
_channel_handler = logging.StreamHandler()
23
_channel_handler.setFormatter(CleanFormatter())
24
25
logger = logging.getLogger("mongomantic")
26
logger.addHandler(_channel_handler)
27