forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogging_utils.py
More file actions
40 lines (35 loc) · 1.27 KB
/
Copy pathlogging_utils.py
File metadata and controls
40 lines (35 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import logging
def configure_logging() -> None:
"""Enable INFO logs for ag_ui_agentspec and pyagentspec and attach a console handler.
Uvicorn's default logging config doesn't automatically show 3rd‑party logger output.
We install a root handler and set levels explicitly so logs appear in the terminal.
"""
root = logging.getLogger()
if not root.handlers:
handler = logging.StreamHandler()
handler.setFormatter(
logging.Formatter("%(asctime)s | %(levelname)s | %(name)s | %(message)s")
)
root.addHandler(handler)
root.setLevel(logging.INFO)
for h in root.handlers:
try:
h.setLevel(logging.INFO)
except Exception:
pass
# Turn on INFO for relevant namespaces and propagate to root
for name in (
"ag_ui_agentspec",
"ag_ui_agentspec.endpoint",
"ag_ui_agentspec.tracing",
"pyagentspec",
"wayflowcore",
):
lg = logging.getLogger(name)
lg.setLevel(logging.INFO)
lg.propagate = True
# Also make uvicorn loggers propagate to our root handler
for name in ("uvicorn", "uvicorn.error", "uvicorn.access"):
lg = logging.getLogger(name)
lg.setLevel(logging.INFO)
lg.propagate = True