mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 12:25:20 +00:00
refactor(logger): Conditionally include extra_json in logs
This commit is contained in:
parent
5eca495d3e
commit
54d606eabf
1 changed files with 6 additions and 2 deletions
|
|
@ -26,12 +26,16 @@ def stdout_format(record: "Record") -> str:
|
||||||
Returns:
|
Returns:
|
||||||
str: A formatted log string intended for stdout.
|
str: A formatted log string intended for stdout.
|
||||||
"""
|
"""
|
||||||
record["extra"]["extra_json"] = json.dumps(record["extra"])
|
if record["extra"]:
|
||||||
|
record["extra"]["extra_json"] = json.dumps(record["extra"])
|
||||||
|
extra_format = " - {extra[extra_json]}"
|
||||||
|
else:
|
||||||
|
extra_format = ""
|
||||||
return (
|
return (
|
||||||
"<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | "
|
"<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | "
|
||||||
"<level>{level: <8}</level> | "
|
"<level>{level: <8}</level> | "
|
||||||
"<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - "
|
"<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - "
|
||||||
"<level>{message}</level> - {extra[extra_json]}"
|
"<level>{message}</level>" + extra_format +
|
||||||
"\n{exception}"
|
"\n{exception}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue