Skip to content

Commit

Permalink
reduce number of kept logs and reduce error snapshot sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
joernhees committed Apr 21, 2017
1 parent 58fa038 commit d6110f1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions logging_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def doRollover(self):
'formatter': 'indenting_formatter',
'filename': filename + '_debug' + LOG_SUFFIX,
'maxBytes': 2 * 1024 ** 2, # 2 MiB
'backupCount': 32,
'backupCount': 4,
'mode': 'a',
'encoding': 'utf-8',
},
Expand All @@ -162,7 +162,7 @@ def doRollover(self):
'formatter': 'indenting_formatter',
'filename': filename + '_info' + LOG_SUFFIX,
'maxBytes': 2 * 1024 ** 2, # 2 MiB
'backupCount': 32,
'backupCount': 4,
'mode': 'a',
'encoding': 'utf-8',
},
Expand Down Expand Up @@ -221,5 +221,10 @@ def save_error_logs():
dir_ = os.path.join(LOG_DIR, time.strftime('error_logs_%Y-%m-%dT%H-%M-%S'))
if not os.path.exists(dir_):
os.mkdir(dir_)
for fn in glob.glob(os.path.join(LOG_DIR, '*.log*')):
shutil.copyfile(fn, os.path.join(dir_, os.path.basename(fn)))
logfiles = glob.glob(os.path.join(LOG_DIR, '*.log')) + \
glob.glob(os.path.join(LOG_DIR, '*.log.01.gz'))
for fn in logfiles:
target = os.path.join(dir_, os.path.basename(fn))
shutil.copyfile(fn, target)
if target.endswith('.log'):
_gzip_file(target)

0 comments on commit d6110f1

Please sign in to comment.