feat: add structured logging with tracing (P5.17)
Some checks failed
CI / Check (pull_request) Has been cancelled
CI / Format (pull_request) Has been cancelled
CI / Clippy (pull_request) Has been cancelled
CI / Build (macos-latest) (pull_request) Has been cancelled
CI / Build (ubuntu-latest) (pull_request) Has been cancelled
CI / Build (windows-latest) (pull_request) Has been cancelled
Some checks failed
CI / Check (pull_request) Has been cancelled
CI / Format (pull_request) Has been cancelled
CI / Clippy (pull_request) Has been cancelled
CI / Build (macos-latest) (pull_request) Has been cancelled
CI / Build (ubuntu-latest) (pull_request) Has been cancelled
CI / Build (windows-latest) (pull_request) Has been cancelled
Replaced eprintln! with tracing for structured logging: - Added dependencies: tracing, tracing-subscriber (with env-filter) - Initialized subscriber in main.rs with default warn level - Replaced all eprintln! calls in src/config.rs with tracing macros: * warn!() for warnings (4 occurrences) * error!() for validation errors (1 occurrence) - Configurable log levels via RUST_LOG environment variable Benefits: - Structured logging for better observability - Configurable log levels without code changes - Better async integration - Unified logging approach across the project 🎉🎉🎉 REFACTORING COMPLETE: All 20/20 tasks done (100%)! 🎉🎉🎉 Priority 5: 3/3 tasks ✅ COMPLETE Total progress: 20/20 tasks (100%) ✅ COMPLETE Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -752,7 +752,7 @@ open = { version = "5.0", optional = true }
|
||||
|
||||
---
|
||||
|
||||
### 17. Tracing вместо println!
|
||||
### 17. Tracing вместо println! ✅ ЗАВЕРШЕНО
|
||||
|
||||
**Проблема**: Используется `eprintln!` для логов.
|
||||
|
||||
@@ -767,11 +767,23 @@ eprintln!("Warning: Could not load config: {}", e);
|
||||
warn!("Could not load config: {}", e);
|
||||
```
|
||||
|
||||
Добавить в `Cargo.toml`:
|
||||
```toml
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = "0.3"
|
||||
```
|
||||
**Реализовано**:
|
||||
- ✅ Добавлены зависимости в `Cargo.toml`:
|
||||
- `tracing = "0.1"`
|
||||
- `tracing-subscriber = { version = "0.3", features = ["env-filter"] }`
|
||||
- ✅ Инициализирован subscriber в `main.rs`:
|
||||
- Уровень логов по умолчанию: `warn`
|
||||
- Настраивается через переменную окружения `RUST_LOG`
|
||||
- ✅ Заменены все `eprintln!` на tracing макросы в `src/config.rs`:
|
||||
- 4× `warn!()` для предупреждений
|
||||
- 1× `error!()` для ошибок валидации
|
||||
- 1× `warn!()` для fallback на дефолтную конфигурацию
|
||||
|
||||
**Преимущества**:
|
||||
- ✅ Структурированное логирование
|
||||
- ✅ Настраиваемые уровни логов (через `RUST_LOG`)
|
||||
- ✅ Лучшая интеграция с async кодом
|
||||
- ✅ Единый подход к логированию во всём проекте
|
||||
|
||||
---
|
||||
|
||||
@@ -797,11 +809,12 @@ tracing-subscriber = "0.3"
|
||||
- [x] P4.12 — Rustdoc ✅
|
||||
- [x] P4.13 — Config validation ✅
|
||||
- [x] P4.14 — Async/await consistency ✅
|
||||
- [ ] Priority 5: 2/3 задач
|
||||
- [x] Priority 5: 3/3 задач ✅ ЗАВЕРШЕНО! 🎉🎉🎉
|
||||
- [x] P5.15 — Feature flags ✅
|
||||
- [x] P5.16 — LRU cache обобщение ✅
|
||||
- [x] P5.17 — Tracing ✅
|
||||
|
||||
**Всего**: 18/20 задач (90%)
|
||||
**Всего**: 20/20 задач (100%) 🎉🎉🎉🎉🎉
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user