Some logging configuration fixes.

log_file_size is now in bytes only. megabytes are obsolete since we all have a calculator... ;)
This commit is contained in:
Johannes Findeisen 2022-10-06 23:14:28 +02:00
commit d179e478eb
2 changed files with 8 additions and 15 deletions

View file

@ -37,7 +37,7 @@ logger = logging.getLogger('linspector')
# i currently only increase the 3rd number because the goal is that 0.19.* will become the first
# stable version.
__version__ = '0.19.38.dev1'
__version__ = '0.19.39.dev1'
__author__ = 'Johannes Findeisen <you@hanez.org>'
@ -111,14 +111,10 @@ def main():
logging.Formatter('[%(asctime)s]:[%(levelname)s]:[%(name)s]:%(message)s')
if configuration.get_option('linspector', 'log_file_size'):
log_file_size_mb = int(configuration.get_option('linspector', 'log_file_size'))
log_file_size_bytes = int(log_file_size_mb * 1000000)
elif configuration.get_option('linspector', 'log_file_size_bytes'):
log_file_size_bytes = int(configuration.get_option('linspector',
'log_file_size_bytes'))
log_file_size = int(configuration.get_option('linspector', 'log_file_size'))
else:
# default log file size is 10MB
log_file_size_bytes = int(10485760)
# default log file size is 10000000 bytes (10MiB)
log_file_size = int(10000000)
if configuration.get_option('linspector', 'log_file_count'):
log_file_count = int(configuration.get_option('linspector', 'log_file_count'))
@ -127,7 +123,7 @@ def main():
log_file_count = 1
log_file_handler = logging.handlers.RotatingFileHandler(log_file,
maxBytes=log_file_size_bytes,
maxBytes=log_file_size,
backupCount=log_file_count)
log_file_handler.setFormatter(log_file_formatter)

View file

@ -7,12 +7,9 @@ log_level= debug
log_file = ~/code/linspector/linspector/log/linspector.log
; number of log files to be kept. i recommend to use the lowest sensible value for keeping performance high. so set
; the size of the log file higher to increase the log history.
log_file_count = 5
; log file size in megabytes as float.
;log_file_size = 1
; log file size in bytes as int. you can set to bytes if you want to set a value lower then 1 megabyte. but it will
; only be used when log_file_size is not set.
;log_file_size_bytes = 10485760
log_file_count = 10
; log file size in bytes as int. the default is 10000000 bytes (10MiB) if not set here to a different value.
log_file_size = 1000000
pid_file = /var/run/user/1000/linspector.pid
; plugins separated by ','. no whitespaces allowed! not case sensitive.
plugins = Lish,HTTPServer