Skip to content
Snippets Groups Projects
Commit a0bb07d0 authored by Thomas Kluyver's avatar Thomas Kluyver
Browse files

Change logfile compression to bzip2

parent 963aa3e8
No related branches found
No related tags found
1 merge request!1074[Webservice] Common log directory, rotate log files weekly
......@@ -4,8 +4,8 @@
# Implement the systemd notify protocol without external dependencies.
# Taken from the sd_notify man page
import bz2
import errno
import gzip
import logging
import os
import shutil
......@@ -45,7 +45,7 @@ def file_and_stderr_logs(path: Path):
# From Python logging cookbook: compress logs when they're rotated
def rotator(source, dest):
with open(source, 'rb') as f_in:
with gzip.open(dest, 'wb') as f_out:
with bz2.open(dest, 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
os.remove(source)
......@@ -55,7 +55,7 @@ def file_and_stderr_logs(path: Path):
atTime=time(12, 0), # At midday (after experiments finish)
backupCount=40, # weeks of logs to keep
)
filehandler.namer = lambda name: name + ".gz"
filehandler.namer = lambda name: name + ".bz2"
filehandler.rotator = rotator
filehandler.setFormatter(logging.Formatter(
'%(asctime)s - %(name)s - %(levelname)s - [%(filename)s:%(lineno)d] %(message)s' # noqa
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment