aboutsummaryrefslogtreecommitdiffstats
path: root/python/utils/__init__.py
blob: 856e42f14b2b824acff58e84cad5d4019711a17c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import logging
import os


class SerenitasFileHandler(logging.FileHandler):
    """simple class that encapsulates where we store our logs"""

    _formatter = logging.Formatter(
        "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
    )

    def __init__(self, log_file):
        super().__init__(filename=os.path.join(os.getenv("LOG_DIR"), log_file))
        self.setFormatter(SerenitasFileHandler._formatter)


class SerenitasRotatingFileHandler(logging.RotatingFileHandler):
    """simple class that encapsulates where we store our logs"""

    def __init__(self, log_file, maxBytes=0):
        super().__init__(
            filename=os.path.join(os.getenv("LOG_DIR"), log_file), maxBytes=maxByes
        )
        self.setFormatter(SerenitasFileHandler._formatter)