mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-15 05:45:19 +00:00
Merge pull request #15640 from ipapapa/feat/cleaner-logs
refactor(logger): Conditionally include extra_json in logs
This commit is contained in:
commit
0b627248f5
1 changed files with 6 additions and 2 deletions
|
|
@ -29,12 +29,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