mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
40 lines
824 B
Python
40 lines
824 B
Python
import time
|
|
import json
|
|
|
|
__log_level = 'debug'
|
|
|
|
|
|
def log(level: str, title: str, *var):
|
|
"""
|
|
通用输出日志方法
|
|
:param level:
|
|
:param var:
|
|
:return:
|
|
"""
|
|
if __log_level == 'error' and level in ['debug', 'info', 'warning']:
|
|
return
|
|
elif __log_level == 'warning' and level in ['debug', 'info']:
|
|
return
|
|
elif __log_level == 'info' and level == 'debug':
|
|
return
|
|
|
|
print('--------- ', title, ' ---------')
|
|
for i in var:
|
|
print('[%r]' % level, i)
|
|
|
|
|
|
def debug(title: str, *var):
|
|
"""
|
|
打印debug日志
|
|
:param title:
|
|
:param var:
|
|
:return:
|
|
"""
|
|
log('debug', title, *var)
|
|
|
|
|
|
testdict = json.loads(
|
|
'{"type":"485","data":[{"addr":"5","options":[{"fun":"x03","opt_addr":0,"data":5}]}]}')
|
|
|
|
debug("testdict", testdict, type(testdict))
|