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:
|
||||
str: A formatted log string intended for stdout.
|
||||
"""
|
||||
if record["extra"]:
|
||||
record["extra"]["extra_json"] = json.dumps(record["extra"])
|
||||
extra_format = " - {extra[extra_json]}"
|
||||
else:
|
||||
extra_format = ""
|
||||
return (
|
||||
"<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | "
|
||||
"<level>{level: <8}</level> | "
|
||||
"<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - "
|
||||
"<level>{message}</level> - {extra[extra_json]}"
|
||||
"<level>{message}</level>" + extra_format +
|
||||
"\n{exception}"
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue