Files
loader/_docs/02_document/modules/constants.md
T
Oleksandr Bezdieniezhnykh 4eaf218f09 Quality cleanup refactoring
Made-with: Cursor
2026-04-13 06:21:26 +03:00

68 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Module: constants
## Purpose
Centralizes shared configuration constants and provides the application-wide logging interface via Loguru.
## Public Interface
### Constants (cdef, module-level)
| Name | Type | Value |
|---------------|------|--------------|
| CDN_CONFIG | str | `"cdn.yaml"` |
| SMALL_SIZE_KB | int | `3` |
Note: `QUEUE_MAXSIZE`, `COMMANDS_QUEUE`, `ANNOTATIONS_QUEUE` are declared in the `.pxd` but not defined in the `.pyx` — they are unused in this codebase.
### Functions (cdef, Cython-only visibility)
| Function | Signature | Description |
|------------------------|----------------------------|------------------------------|
| `log` | `cdef log(str log_message)` | Logs at INFO level via Loguru |
| `logerror` | `cdef logerror(str error)` | Logs at ERROR level via Loguru |
## Internal Logic
Loguru is configured with three sinks:
- **File sink**: under `LOG_DIR`, path template `log_loader_{time:YYYYMMDD}.txt`, INFO level, daily rotation, 30-day retention, async (enqueue=True)
- **Stdout sink**: DEBUG level, filtered to INFO/DEBUG/SUCCESS only, colorized
- **Stderr sink**: WARNING+ level, colorized
Log format: `[HH:mm:ss LEVEL] message`
## Dependencies
- **Internal**: none (leaf module)
- **External**: `loguru` (0.7.3), `os`, `sys`
## Consumers
- `hardware_service` — calls `log()`
- `cdn_manager` — calls `log()`, `logerror()`
- `api_client` — calls `log()`, `logerror()`, reads `CDN_CONFIG`, `SMALL_SIZE_KB`
## Data Models
None.
## Configuration
| Env Variable | Default | Description |
|--------------|---------|--------------------------------------|
| LOG_DIR | `Logs` | Directory for daily log files |
The file sink uses Logurus `{time:YYYYMMDD}` in the filename under `LOG_DIR`.
## External Integrations
None.
## Security
None.
## Tests
No tests found.