修复一些问题
This commit is contained in:
		@@ -1,7 +1,7 @@
 | 
			
		||||
import sqlite3
 | 
			
		||||
import time
 | 
			
		||||
from inspect import currentframe
 | 
			
		||||
from functools import singledispatch
 | 
			
		||||
from functools import singledispatch, wraps
 | 
			
		||||
 | 
			
		||||
from codes.common import clibs
 | 
			
		||||
 | 
			
		||||
@@ -45,7 +45,9 @@ def db_init():
 | 
			
		||||
    conn.close()
 | 
			
		||||
 | 
			
		||||
def db_lock(func):
 | 
			
		||||
    @wraps(func)
 | 
			
		||||
    def wrapper(*args, **kwargs):
 | 
			
		||||
        clibs.caller_frame = currentframe().f_back
 | 
			
		||||
        try:
 | 
			
		||||
            clibs.lock.acquire(True)
 | 
			
		||||
            ret = func(*args, **kwargs)
 | 
			
		||||
@@ -93,11 +95,11 @@ def db_close():
 | 
			
		||||
 | 
			
		||||
@db_lock
 | 
			
		||||
def db_write_logs(content, module="", level="info"):
 | 
			
		||||
    if module == "":
 | 
			
		||||
        frame = currentframe().f_back
 | 
			
		||||
        module_name = frame.f_globals["__name__"]
 | 
			
		||||
        line_no = frame.f_lineno
 | 
			
		||||
        module = f"{module_name}.{line_no}"
 | 
			
		||||
    if module == "" and clibs.caller_frame is not None:
 | 
			
		||||
        module_name = clibs.caller_frame.f_globals["__name__"].split(".")[-1]  #
 | 
			
		||||
        func_name = clibs.caller_frame.f_code.co_name
 | 
			
		||||
        line_no = clibs.caller_frame.f_lineno
 | 
			
		||||
        module = f"{module_name}-{func_name}:{line_no}"
 | 
			
		||||
 | 
			
		||||
    if level.lower() not in ["info", "warning", "error", "exception"]:
 | 
			
		||||
        level = "unknown"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user