Skip to content

Commit 427fb79

Browse files
committed
Merge config into a deep copy of the uvicorn logging config
1 parent 25c78e2 commit 427fb79

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/log.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import sys
77
import typing as t
8+
from copy import deepcopy
89
from datetime import datetime
910
from functools import lru_cache
1011

@@ -112,7 +113,8 @@ def setup_logging() -> dict[t.Any, t.Any]:
112113
},
113114
}
114115

115-
merged_config = deep_update(uvicorn.config.LOGGING_CONFIG, logging_conf)
116+
# Create a deep copy of uvicorn's logging config to avoid mutating global state.
117+
merged_config = deep_update(deepcopy(uvicorn.config.LOGGING_CONFIG), logging_conf)
116118

117119
if handler == "rich":
118120
merged_config["loggers"]["uvicorn"]["handlers"] = [handler]

0 commit comments

Comments
 (0)