Added process name and thread ID to logging.
This commit is contained in:
parent
35edb0204e
commit
4ae153f3be
3 changed files with 21 additions and 13 deletions
|
|
@ -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.51.dev1'
|
||||
__version__ = '0.19.52.dev1'
|
||||
__author__ = 'Johannes Findeisen <you@hanez.org>'
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ log_file_count = 10
|
|||
; log file size in megabytes as int. the default is 10000000 bytes (10MiB) set in the code if not configured here.
|
||||
log_file_size = 5
|
||||
; 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.
|
||||
; only be used when log_file_size is not set. if this value is not set too the default in the code will be used.
|
||||
log_file_size_bytes = 100000
|
||||
pid_file = /var/run/user/1000/linspector.pid
|
||||
; plugins separated by ','. no whitespaces allowed! not case sensitive.
|
||||
|
|
@ -43,7 +43,7 @@ max_threads = 2048
|
|||
; i recommend to set this to your number of CPU cores available when running on a dedicated Linspector host. but if the
|
||||
; system is running other services you should lower this value when you have too high CPU load. if you have enough
|
||||
; resources this value really can be higher then your available CPU cores.
|
||||
max_processes = 48
|
||||
max_processes = 12
|
||||
; if timezone is not set, UTC is used by default.
|
||||
timezone = CET
|
||||
; this is for scheduling jobs to not run all at the same time. this should be set to the lowest interval you use. it
|
||||
|
|
|
|||
|
|
@ -12,25 +12,33 @@ def log(level, msg):
|
|||
# only use inspect when log level NOTSET or DEBUG is enabled.
|
||||
if logger.isEnabledFor(0) or logger.isEnabledFor(10):
|
||||
import inspect
|
||||
import multiprocessing
|
||||
import threading
|
||||
current_process = multiprocessing.current_process()
|
||||
from_stack = inspect.stack()[1]
|
||||
function_name = from_stack.function
|
||||
line_number = str(from_stack.lineno)
|
||||
module_name = inspect.getmodule(from_stack[0]).__name__
|
||||
if level == 'critical':
|
||||
logger.critical('[' + module_name + ']:[' + function_name + ']:[' + line_number + '] ' +
|
||||
str(msg))
|
||||
logger.critical('[' + str(current_process.name) + ']:[' + str(threading.get_ident()) +
|
||||
']:[' + str(threading.get_native_id()) + '] [' + module_name + ']:[' +
|
||||
function_name + ']:[' + line_number + '] ' + str(msg))
|
||||
if level == 'error':
|
||||
logger.error('[' + module_name + ']:[' + function_name + ']:[' + line_number + '] ' +
|
||||
str(msg))
|
||||
logger.error('[' + str(current_process.name) + ']:[' + str(threading.get_ident()) +
|
||||
']:[' + str(threading.get_native_id()) + '] [' + module_name + ']:[' +
|
||||
function_name + ']:[' + line_number + '] ' + str(msg))
|
||||
elif level == 'warning':
|
||||
logger.warning('[' + module_name + ']:[' + function_name + ']:[' + line_number + '] ' +
|
||||
str(msg))
|
||||
logger.warning('[' + str(current_process.name) + ']:[' + str(threading.get_ident()) +
|
||||
']:[' + str(threading.get_native_id()) + '] [' + module_name + ']:[' +
|
||||
function_name + ']:[' + line_number + '] ' + str(msg))
|
||||
elif level == 'info':
|
||||
logger.info('[' + module_name + ']:[' + function_name + ']:[' + line_number + '] ' +
|
||||
str(msg))
|
||||
logger.info('[' + str(current_process.name) + ']:[' + str(threading.get_ident()) +
|
||||
']:[' + str(threading.get_native_id()) + '] [' + module_name + ']:[' +
|
||||
function_name + ']:[' + line_number + '] ' + str(msg))
|
||||
elif level == 'debug':
|
||||
logger.debug('[' + module_name + ']:[' + function_name + ']:[' + line_number + '] ' +
|
||||
str(msg))
|
||||
logger.debug('[' + str(current_process.name) + ']:[' + str(threading.get_ident()) +
|
||||
']:[' + str(threading.get_native_id()) + '] [' + module_name + ']:[' +
|
||||
function_name + ']:[' + line_number + '] ' + str(msg))
|
||||
else:
|
||||
if level == 'critical':
|
||||
logger.critical(str(msg))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue