#15 - Implement Backpressure UPDATE & IDLE, setup AMQ handler in its own thread
This commit is contained in:
@@ -2,6 +2,7 @@ import inspect
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
import traceback
|
||||
|
||||
verbose = os.environ.get("AMQ_VERBOSE_LOGGING", "0") == "1"
|
||||
@@ -46,21 +47,22 @@ def logging_error(msg: str, *args) -> None:
|
||||
msg (str): The error message to log.
|
||||
"""
|
||||
_exec_info = sys.exc_info()[2]
|
||||
_thread_id = threading.get_ident()
|
||||
if _exec_info:
|
||||
_tb = traceback.extract_tb(sys.exc_info()[2])[-1]
|
||||
logging.error(
|
||||
f" [E] '{msg}' ---> '{_tb.filename}':{_tb.lineno}, '{_tb.name}()'",
|
||||
f"{_thread_id} [E] '{msg}' ---> '{_tb.filename}':{_tb.lineno}, '{_tb.name}()'",
|
||||
*args,
|
||||
)
|
||||
else:
|
||||
module, line_number, function_name = get_context_info()
|
||||
if module and line_number and function_name:
|
||||
logging.error(
|
||||
f" [E] '{msg}' ---> '{module}':{line_number}, '{function_name}()'",
|
||||
f"{_thread_id} [E] '{msg}' ---> '{module}':{line_number}, '{function_name}()'",
|
||||
*args,
|
||||
)
|
||||
else:
|
||||
logging.error(f" [E] {msg}", *args)
|
||||
logging.error(f"{_thread_id} [E] {msg}", *args)
|
||||
|
||||
|
||||
def logging_warning(msg: str, *args) -> None:
|
||||
@@ -70,17 +72,18 @@ def logging_warning(msg: str, *args) -> None:
|
||||
Args:
|
||||
msg (str): The warning message to log.
|
||||
"""
|
||||
_thread_id = threading.get_ident()
|
||||
if not verbose:
|
||||
logging.warning(f" [W] {msg}", *args)
|
||||
logging.warning(f"{_thread_id} [W] {msg}", *args)
|
||||
return
|
||||
module, line_number, function_name = get_context_info()
|
||||
if module and line_number and function_name:
|
||||
logging.warning(
|
||||
f" [W] '{msg}' ---> '{module}':{line_number}, '{function_name}()'",
|
||||
f"{_thread_id} [W] '{msg}' ---> '{module}':{line_number}, '{function_name}()'",
|
||||
*args,
|
||||
)
|
||||
else:
|
||||
logging.warning(f" [W] {msg}", *args)
|
||||
logging.warning(f"{_thread_id} [W] {msg}", *args)
|
||||
|
||||
|
||||
def logging_info(msg: str, *args) -> None:
|
||||
@@ -90,17 +93,18 @@ def logging_info(msg: str, *args) -> None:
|
||||
Args:
|
||||
msg (str): The info message to log.
|
||||
"""
|
||||
_thread_id = threading.get_ident()
|
||||
if not verbose:
|
||||
logging.info(f" [*] {msg}", *args)
|
||||
logging.info(f"{_thread_id} [*] {msg}", *args)
|
||||
return
|
||||
module, line_number, function_name = get_context_info()
|
||||
if module and line_number and function_name:
|
||||
logging.info(
|
||||
f" [*] '{msg}' ---> '{module}':{line_number}, '{function_name}()'",
|
||||
f"{_thread_id} [*] '{msg}' ---> '{module}':{line_number}, '{function_name}()'",
|
||||
*args,
|
||||
)
|
||||
else:
|
||||
logging.info(f" [*] {msg}", *args)
|
||||
logging.info(f"{_thread_id} [*] {msg}", *args)
|
||||
|
||||
|
||||
def logging_debug(msg: str, *args) -> None:
|
||||
@@ -110,11 +114,12 @@ def logging_debug(msg: str, *args) -> None:
|
||||
Args:
|
||||
msg (str): The debug message to log.
|
||||
"""
|
||||
_thread_id = threading.get_ident()
|
||||
module, line_number, function_name = get_context_info()
|
||||
if module and line_number and function_name:
|
||||
logging.info(
|
||||
f" [DBG] '{msg}' ---> '{module}':{line_number}, '{function_name}()'",
|
||||
f"{_thread_id} [DBG] '{msg}' ---> '{module}':{line_number}, '{function_name}()'",
|
||||
*args,
|
||||
)
|
||||
else:
|
||||
logging.debug(f" [DBG] {msg}", *args)
|
||||
logging.debug(f"{_thread_id} [DBG] {msg}", *args)
|
||||
|
||||
Reference in New Issue
Block a user