f
This commit is contained in:
@@ -4,9 +4,17 @@ import sys
|
||||
import inspect
|
||||
import threading
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from SYS.rich_display import console_for
|
||||
|
||||
# Global DB logger set later to avoid circular imports
|
||||
_DB_LOGGER = None
|
||||
|
||||
def set_db_logger(func):
|
||||
global _DB_LOGGER
|
||||
_DB_LOGGER = func
|
||||
|
||||
_DEBUG_ENABLED = False
|
||||
_thread_local = threading.local()
|
||||
|
||||
@@ -207,6 +215,15 @@ def log(*args, **kwargs) -> None:
|
||||
console_for(file).print(prefix, *args, sep=sep, end=end)
|
||||
else:
|
||||
console_for(file).print(*args, sep=sep, end=end)
|
||||
|
||||
# Log to database if available
|
||||
if _DB_LOGGER:
|
||||
try:
|
||||
msg = sep.join(map(str, args))
|
||||
level = "DEBUG" if add_prefix else "INFO"
|
||||
_DB_LOGGER(level, f"{file_name}.{func_name}", msg)
|
||||
except Exception:
|
||||
pass
|
||||
finally:
|
||||
del frame
|
||||
del caller_frame
|
||||
|
||||
Reference in New Issue
Block a user