summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/core/logs.py
blob: b8ba3ba3f59863191e0afa0aa8a4c7ed53f5dfad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from os import makedirs
from os.path import abspath, join, isfile

from twisted.python import logfile

from leap.common.config import get_path_prefix


def loggerFactory():
    configdir = abspath(join(get_path_prefix(), 'leap'))
    if not configdir:
        makedirs(configdir)
    log_path = abspath(join(get_path_prefix(), 'leap', 'bitmaskd.log'))
    rotate = isfile(log_path)
    _logfile = logfile.LogFile.fromFullPath(log_path, maxRotatedFiles=5)
    if rotate:
        _logfile.rotate()
    return _logfile