You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -195,6 +195,48 @@ Received message on main namespace. SID: FI3E_S_A-KsTi4RLAAAD, Message: Hello fr
195
195
Yes, the socket logs are also within the trace. The trace ID - `S-4e2b7c5e` and `S-aaf46528` was added to the log messages. For better experience, the prefix `S` was added to the trace ID to differentiate it from the request ID.
196
196
197
197
198
+
### Uvicorn Integration
199
+
200
+
```python
201
+
from chromatrace.uvicorn import GetLoggingConfig, UvicornLoggingSettings
202
+
203
+
rest_application = FastAPI()
204
+
205
+
uvicorn.run(
206
+
rest_application,
207
+
host="0.0.0.0",
208
+
port=8000,
209
+
log_level="debug",
210
+
log_config=GetLoggingConfig(
211
+
UvicornLoggingSettings(
212
+
enable_file_logging=True,
213
+
show_process_id=True,
214
+
)
215
+
),
216
+
)
217
+
```
218
+
219
+
Result:
220
+
```log
221
+
(2024-12-12 20:54:54)-[PID:3710345]-[INFO]: Started server process [3710345]
222
+
(2024-12-12 20:54:54)-[PID:3710345]-[INFO]: Waiting for application startup.
(2024-12-12 21:16:45)-[PID:3710345]-[INFO]: Finished server process [3710345]
235
+
```
236
+
237
+
The logs are within the process ID - `PID:3710345` was added to the log messages. The log messages are also colored for better visibility. The log messages are also written to the file if the `enable_file_logging` is set to `True`. For more information, check the [config.py](src/chromatrace/uvicorn/config.py) file, `UvicornLoggingSettings` class.
238
+
239
+
198
240
## Examples
199
241
200
242
> You don't trust me, do you? I understand. You wanna see it in action, right? I got you covered. :)
0 commit comments