Removed logging to stdout & stderr to be prepared for Lish. (0.27.0)
This commit is contained in:
parent
971ec6329f
commit
362b1dfb7c
3 changed files with 20 additions and 34 deletions
|
|
@ -20,9 +20,11 @@ from linspector.environment import Environment
|
|||
from linspector.linspector import Linspector
|
||||
from linspector.monitors import Monitors
|
||||
|
||||
__version__ = '0.26.1'
|
||||
__version__ = '0.27.0'
|
||||
__author__ = 'Johannes Findeisen <you@hanez.org>'
|
||||
|
||||
sys.stderr = open('/dev/null', 'w')
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
|
|
@ -58,28 +60,15 @@ def linspector():
|
|||
services = {}
|
||||
tasks = {}
|
||||
|
||||
try:
|
||||
configuration = Configuration(args.configuration_path)
|
||||
except Exception as err:
|
||||
print('configuration error: {0}'.format(err))
|
||||
sys.exit(1)
|
||||
|
||||
log.remove()
|
||||
default_log_format = 'timestamp={time:YYYY-MM-DD HH:mm:ss.SSSSSS ZZ} uptime={elapsed} level={level} ' \
|
||||
'name=linspector exec={name}:{function} line={line} {message}'
|
||||
log_level = "INFO"
|
||||
log.add(sys.stderr, backtrace=True, colorize=True, diagnose=True, format=default_log_format, level=log_level)
|
||||
|
||||
try:
|
||||
configuration = Configuration(args.configuration_path, log)
|
||||
except Exception as err:
|
||||
log.error('configuration error: {0}'.format(err))
|
||||
sys.exit(1)
|
||||
|
||||
if configuration.get_option('linspector', 'log_format') or configuration.get_option('linspector', 'log_level'):
|
||||
log.remove()
|
||||
log_format = default_log_format
|
||||
if configuration.get_option('linspector', 'log_format'):
|
||||
log_format = configuration.get_option('linspector', 'log_format')
|
||||
|
||||
if configuration.get_option('linspector', 'log_level'):
|
||||
log_level = configuration.get_option('linspector', 'log_level')
|
||||
|
||||
log.add(sys.stderr, backtrace=True, colorize=True, diagnose=True, format=log_format, level=log_level)
|
||||
|
||||
if configuration.get_option('linspector', 'logfile'):
|
||||
logfile_count = '10'
|
||||
|
|
@ -90,7 +79,7 @@ def linspector():
|
|||
if configuration.get_option('linspector', 'logfile_format'):
|
||||
logfile_format = configuration.get_option('linspector', 'logfile_format')
|
||||
|
||||
logfile_level = log_level
|
||||
logfile_level = 'INFO'
|
||||
if configuration.get_option('linspector', 'logfile_level'):
|
||||
logfile_level = configuration.get_option('linspector', 'logfile_level')
|
||||
|
||||
|
|
@ -105,7 +94,8 @@ def linspector():
|
|||
|
||||
try:
|
||||
if configuration.get_option('linspector', 'tasks'):
|
||||
log.info('Loading tasks: ' + configuration.get_option('linspector', 'tasks'))
|
||||
log.info('loading tasks: ' + configuration.get_option('linspector', 'tasks'))
|
||||
print('Loading tasks: ' + configuration.get_option('linspector', 'tasks'))
|
||||
task_list = configuration.get_option('linspector', 'tasks')
|
||||
task_list = task_list.split(',')
|
||||
for task_name in task_list:
|
||||
|
|
@ -155,6 +145,7 @@ def linspector():
|
|||
signal.pause()
|
||||
except KeyboardInterrupt:
|
||||
log.info('program terminated by user!')
|
||||
print('Program terminated by user!')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -9,19 +9,16 @@ max_processes = 1
|
|||
max_threads = 2048
|
||||
pid_file = /var/run/user/1000/linspector.pid
|
||||
|
||||
; log format. this overrides the default configured in the code
|
||||
log_format = <green>[{time:YYYY-MM-DD HH:mm:ss.SSSSSS ZZ}]</green> <yellow>[{elapsed}]</yellow> <magenta>[{level}]</magenta> <blue>[linspector]</blue> <cyan>[{name}:{function}:{line}]</cyan><red>:</red> {message}
|
||||
; log level for stderr logging (default: INFO)
|
||||
log_level = INFO
|
||||
; logfile to use
|
||||
; logfile to use (if not set set no output will be logged somewhere)
|
||||
logfile = /home/hanez/code/linspector/linspector/log/linspector.log
|
||||
; number of logfiles to keep (default: 10)
|
||||
logfile_count = 5
|
||||
logfile_count = 10
|
||||
; logfile format. this overrides the default configured in the code
|
||||
;logfile_format = [{time:YYYY-MM-DD HH:mm:ss.SSSSSS ZZ}] [{elapsed}] [{level}] [linspector] [{name}:{function}:{line}]: {message}
|
||||
; log level for file based logging
|
||||
logfile_level = DEBUG
|
||||
; size of logfiles (default: 1MB)
|
||||
logfile_format = [{time:YYYY-MM-DD HH:mm:ss.SSSSSS ZZ}] [{elapsed}] [{level}] [linspector]: {message}
|
||||
; log level (default: INFO)
|
||||
logfile_level = INFO
|
||||
; max logfile size (default: 1MB)
|
||||
logfile_size = 10MB
|
||||
|
||||
notifications =
|
||||
|
|
|
|||
|
|
@ -10,13 +10,11 @@ import os
|
|||
|
||||
|
||||
class Configuration:
|
||||
def __init__(self, configuration_path, log):
|
||||
def __init__(self, configuration_path):
|
||||
self._configuration = configparser.ConfigParser()
|
||||
self._configuration_path = configuration_path
|
||||
self._log = log
|
||||
|
||||
log.info('message=reading configuration configfile=' + configuration_path +
|
||||
'/linspector.conf')
|
||||
print('Reading configuration file: ' + configuration_path + '/linspector.conf')
|
||||
if os.path.isfile(configuration_path + '/linspector.conf'):
|
||||
try:
|
||||
self._configuration.read(configuration_path + '/linspector.conf', 'utf-8')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue