优化日志格式bug
parent
d4b49cecf5
commit
ec4e3d8a37
|
@ -77,9 +77,10 @@ class DeptInitSerializer(CustomModelSerializer):
|
||||||
menu_data['parent'] = instance.id
|
menu_data['parent'] = instance.id
|
||||||
filter_data = {
|
filter_data = {
|
||||||
"name": menu_data['name'],
|
"name": menu_data['name'],
|
||||||
"parent": menu_data['parent'],
|
"parent": menu_data['parent']
|
||||||
"key": menu_data['key']
|
|
||||||
}
|
}
|
||||||
|
if 'key' in menu_data:
|
||||||
|
filter_data['key'] = menu_data['key']
|
||||||
instance_obj = Dept.objects.filter(**filter_data).first()
|
instance_obj = Dept.objects.filter(**filter_data).first()
|
||||||
if instance_obj and not self.initial_data.get('reset'):
|
if instance_obj and not self.initial_data.get('reset'):
|
||||||
continue
|
continue
|
||||||
|
@ -147,12 +148,12 @@ class DeptViewSet(CustomModelViewSet):
|
||||||
parent = params.get('parent', None)
|
parent = params.get('parent', None)
|
||||||
if params:
|
if params:
|
||||||
if parent:
|
if parent:
|
||||||
queryset = self.queryset.filter(status=True, parent=parent)
|
queryset = self.queryset.filter(parent=parent)
|
||||||
else:
|
else:
|
||||||
queryset = self.queryset.filter(status=True)
|
queryset = self.queryset.filter(parent__isnull=True)
|
||||||
else:
|
else:
|
||||||
queryset = self.queryset.filter(status=True, parent__isnull=True)
|
queryset = self.queryset.filter(parent__isnull=True)
|
||||||
queryset = self.filter_queryset(queryset)
|
queryset = self.filter_queryset(queryset.order_by('sort', 'create_datetime'))
|
||||||
serializer = DeptSerializer(queryset, many=True, request=request)
|
serializer = DeptSerializer(queryset, many=True, request=request)
|
||||||
data = serializer.data
|
data = serializer.data
|
||||||
return SuccessResponse(data=data)
|
return SuccessResponse(data=data)
|
||||||
|
|
|
@ -24,7 +24,7 @@ class InterceptTimedRotatingFileHandler(RotatingFileHandler):
|
||||||
filename = os.path.abspath(filename)
|
filename = os.path.abspath(filename)
|
||||||
# 定义默认格式
|
# 定义默认格式
|
||||||
if not format:
|
if not format:
|
||||||
format = "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <green>{extra[client_addr]:^18}</green> | <level>{level: <8}</level>| <cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>"
|
format = "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <green>{extra[client_addr]:^18}</green> | <level>{level: <8}</level>| <cyan>{message}</cyan>"
|
||||||
when = when.lower()
|
when = when.lower()
|
||||||
# 2.🎖️需要本地用不同的文件名做为不同日志的筛选器
|
# 2.🎖️需要本地用不同的文件名做为不同日志的筛选器
|
||||||
logger.configure(
|
logger.configure(
|
||||||
|
@ -116,10 +116,12 @@ class InterceptTimedRotatingFileHandler(RotatingFileHandler):
|
||||||
elif isinstance(record.args, tuple) and len(record.args) > 0:
|
elif isinstance(record.args, tuple) and len(record.args) > 0:
|
||||||
if ":" in str(record.args[0]):
|
if ":" in str(record.args[0]):
|
||||||
record_client = record.args[0]
|
record_client = record.args[0]
|
||||||
msg = f"{msg.split('-')[1].strip(' ')}"
|
if msg.split("-") and len(msg.split("-")) == 2:
|
||||||
|
msg = f"{msg.split('-')[1].strip(' ')}"
|
||||||
elif isinstance(record.args[0], tuple) and len(record.args[0]) == 2:
|
elif isinstance(record.args[0], tuple) and len(record.args[0]) == 2:
|
||||||
record_client = f"{record.args[0][0]}:{record.args[0][1]}"
|
record_client = f"{record.args[0][0]}:{record.args[0][1]}"
|
||||||
msg = f"{msg.split('-')[1].strip(' ')}"
|
if msg.split("-") and len(msg.split("-")) == 2:
|
||||||
|
msg = f"{msg.split('-')[1].strip(' ')}"
|
||||||
client = record_client or (details and details.get('client'))
|
client = record_client or (details and details.get('client'))
|
||||||
if client:
|
if client:
|
||||||
bind["client_addr"] = client
|
bind["client_addr"] = client
|
||||||
|
|
Loading…
Reference in New Issue