borgend/loggers.py

changeset 81
7bcd715f19e3
parent 80
a409242121d5
child 86
2fe66644c50d
equal deleted inserted replaced
80:a409242121d5 81:7bcd715f19e3
17 17
18 loglevel=logging.INFO 18 loglevel=logging.INFO
19 logfmt="%(asctime)s:%(levelname)s:%(name)s:%(message)s" 19 logfmt="%(asctime)s:%(levelname)s:%(name)s:%(message)s"
20 fifo_capacity=1000 20 fifo_capacity=1000
21 fifo_fmt="%(asctime)s:%(levelname)s:%(message)s" 21 fifo_fmt="%(asctime)s:%(levelname)s:%(message)s"
22 fileslog_config={
23 'when': 'midnight',
24 'interval': 1,
25 'backupCount': 7
26 }
27
22 28
23 # 29 #
24 # Setting up the main logger with fifo, stderr, and rotating files output 30 # Setting up the main logger with fifo, stderr, and rotating files output
25 # 31 #
26 32
44 if not os.path.isdir(locations.logs_dir): 50 if not os.path.isdir(locations.logs_dir):
45 os.makedirs(locations.logs_dir) 51 os.makedirs(locations.logs_dir)
46 52
47 fileslog=logging.handlers.TimedRotatingFileHandler( 53 fileslog=logging.handlers.TimedRotatingFileHandler(
48 os.path.join(locations.logs_dir, branding.appname+'.log'), 54 os.path.join(locations.logs_dir, branding.appname+'.log'),
49 when='D', interval=1) 55 **fileslog_config)
50 fileslog.setFormatter(logging.Formatter(logfmt)) 56 fileslog.setFormatter(logging.Formatter(logfmt))
51 mainlogger.addHandler(fileslog) 57 mainlogger.addHandler(fileslog)
52 58
53 atexit.register(logging.shutdown) 59 atexit.register(logging.shutdown)
54 60

mercurial