MCPcopy Create free account
hub / github.com/CopilotKit/with-agent-spec / configure_logging

Function configure_logging

agent/src/logging_utils.py:3–37  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

1import logging
2
3def configure_logging() -> None:
4 """Enable INFO logs for ag_ui_agentspec and pyagentspec and attach a console handler.
5
6 Uvicorn's default logging config doesn't automatically show 3rd‑party logger output.
7 We install a root handler and set levels explicitly so logs appear in the terminal.
8 """
9 root = logging.getLogger()
10 if not root.handlers:
11 handler = logging.StreamHandler()
12 handler.setFormatter(logging.Formatter("%(asctime)s | %(levelname)s | %(name)s | %(message)s"))
13 root.addHandler(handler)
14 root.setLevel(logging.INFO)
15 for h in root.handlers:
16 try:
17 h.setLevel(logging.INFO)
18 except Exception:
19 pass
20
21 # Turn on INFO for relevant namespaces and propagate to root
22 for name in (
23 "ag_ui_agentspec",
24 "ag_ui_agentspec.endpoint",
25 "ag_ui_agentspec.tracing",
26 "pyagentspec",
27 "wayflowcore",
28 ):
29 lg = logging.getLogger(name)
30 lg.setLevel(logging.INFO)
31 lg.propagate = True
32
33 # Also make uvicorn loggers propagate to our root handler
34 for name in ("uvicorn", "uvicorn.error", "uvicorn.access"):
35 lg = logging.getLogger(name)
36 lg.setLevel(logging.INFO)
37 lg.propagate = True

Callers 1

build_serverFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected