llama-stack-mirror/llama_stack
Ashwin Bharambe 754feba61f
feat: add a configurable category-based logger (#1352)
A self-respecting server needs good observability which starts with
configurable logging. Llama Stack had little until now. This PR adds a
`logcat` facility towards that. Callsites look like:

```python
logcat.debug("inference", f"params to ollama: {params}")
```

- the first parameter is a category. there is a static list of
categories in `llama_stack/logcat.py`
- each category can be associated with a log-level which can be
configured via the `LLAMA_STACK_LOGGING` env var.
- a value `LLAMA_STACK_LOGGING=inference=debug;server=info"` does the
obvious thing. there is a special key called `all` which is an alias for
all categories

## Test Plan

Ran with `LLAMA_STACK_LOGGING="all=debug" llama stack run fireworks` and
saw the following:


![image](https://github.com/user-attachments/assets/d24b95ab-3941-426c-9ea0-a4c62542e6f0)

Hit it with a client-sdk test case and saw this:


![image](https://github.com/user-attachments/assets/3fee8c6c-986e-4125-a09c-f5dc019682e2)
2025-03-02 18:51:14 -08:00
..
apis feat: enhance OpenAPI spec to include Error types (#1320) 2025-02-28 11:16:12 -08:00
cli chore: remove straggler references to llama-models (#1345) 2025-03-01 14:26:03 -08:00
distribution feat: add a configurable category-based logger (#1352) 2025-03-02 18:51:14 -08:00
models/llama chore: remove straggler references to llama-models (#1345) 2025-03-01 14:26:03 -08:00
providers feat: add a configurable category-based logger (#1352) 2025-03-02 18:51:14 -08:00
scripts chore: remove straggler references to llama-models (#1345) 2025-03-01 14:26:03 -08:00
strong_typing Ensure that deprecations for fields follow through to OpenAPI 2025-02-19 13:54:04 -08:00
templates chore: remove straggler references to llama-models (#1345) 2025-03-01 14:26:03 -08:00
__init__.py export LibraryClient 2024-12-13 12:08:00 -08:00
logcat.py feat: add a configurable category-based logger (#1352) 2025-03-02 18:51:14 -08:00
schema_utils.py ci: add mypy for static type checking (#1101) 2025-02-21 13:15:40 -08:00