Repository navigation
Description
Summary
The codebase has inconsistent logging practices across both frontend and backend. While logging infrastructure exists (TypeScript Logger utility and Rust tracing), it's largely unused. This issue tracks the comprehensive migration to consistent, structured logging.
Current State Analysis
Frontend (TypeScript/Svelte)
- 328 total console statements across the codebase
- 126
console.log(informational - many should be debug or use Logger) - 96
console.error(appropriate for errors) - 72
console.warn(appropriate for warnings) - 31
console.debug(appropriate) - 3
console.info(should use Logger)
- 126
- Logger utility exists at `src/lib/utils/logger.ts` but 0 files import it
- ~42 console.log in test files (acceptable for test output)
Heavy Offenders (console.log count):
- `browser-sync-service.ts`: 16
- `developer-inspector.ts`: 9
- `base-node-viewer.svelte`: 7
- `app-shell.svelte`: 7
- `schema-plugin-loader.ts`: 6
- `app-initialization.ts`: 5
- Various node type files: 2-4 each
Backend (Rust)
- 130 total logging statements
- 28 `println!` (startup messages in dev binaries - acceptable)
- 24 `eprintln!` (error messages - should use tracing::error!)
- 28 `tracing::info!` (proper usage)
- 12 `tracing::debug!` (proper usage)
- 10 `tracing::error!` (proper usage)
- Mixed `warn!/error!/debug!/info!` macros (11 total)
- tracing crate configured in Cargo.toml but inconsistently used
- Dev binaries (`dev-mcp.rs`, `dev-proxy.rs`) use `println!` for startup - appropriate for CLI output
Proposed Solution
Phase 1: Frontend Logger Migration
1.1 Enhance existing Logger utility:
```typescript
// Current: basic logger with prefix support
// Enhance with:
- Environment-aware default levels (dev: debug, prod: warn)
- Structured data support with proper formatting
- Group/timing utilities for debugging
- Color-coded output in development
```
1.2 Migration strategy for console statements:
| Current | New | Criteria |
|---|---|---|
| `console.log` (info) | `logger.info()` | Operational info user/dev should see |
| `console.log` (debug) | `logger.debug()` | Debug info only for troubleshooting |
| `console.error` | `logger.error()` | Actual errors |
| `console.warn` | `logger.warn()` | Warnings that don't block operation |
| `console.debug` | `logger.debug()` | Already debug level |
1.3 Files to migrate (priority order):
- Services (~40 console.log) - core business logic
- Components (~15 console.log) - UI components
- Plugins (~9 console.log) - plugin system
- Types (~16 console.log) - node type definitions
- Utils (~3 console.log) - utility functions
Phase 2: Backend Tracing Standardization
2.1 Standardize on tracing macros:
- Replace remaining `println!` in library code with `tracing::info!`
- Replace `eprintln!` with `tracing::error!`
- Keep `println!` in `main()` functions for CLI startup banners (user-facing)
- Use consistent macro style: `tracing::level!` not bare `level!`
2.2 Files to update:
- `src/lib.rs` - any println! in library code
- `src/commands/db.rs` - database command logging
- Review other modules for consistency
Phase 3: ESLint Rules (Optional)
Add ESLint rules to prevent regression:
```javascript
'no-console': ['warn', { allow: ['warn', 'error', 'debug'] }]
```
Acceptance Criteria
Must Have
- All frontend services use Logger instead of raw console.*
- All frontend components use Logger instead of raw console.*
- All frontend plugins use Logger instead of raw console.*
- Logger utility enhanced with environment-aware defaults
- Production console clean - only errors/warnings visible by default
- Debug logs work via browser devtools level filtering
- Backend library code uses tracing consistently (no println! in lib)
- Test files excluded from migration (console.log acceptable in tests)
Nice to Have
- ESLint rule to warn on new console.log usage
- Logging documentation added to development guide
- Performance impact verified (Logger overhead minimal)
Implementation Notes
Frontend Logger already exists at:
`packages/desktop-app/src/lib/utils/logger.ts`
Features already implemented:
- Test-aware (auto-disables in VITEST)
- Log level filtering
- Prefix support for service identification
- Structured data parameter support
Rust tracing already configured in:
`packages/desktop-app/src-tauri/Cargo.toml`
- tracing = "0.1"
- tracing-subscriber with env-filter
References
- Original issue emerged from Add editable header area to BaseNodeViewer #361 where informational logs appeared during navigation
- Logger utility implemented but never adopted across codebase
Activity
malibio commentedon Dec 4, 2025
Test baseline: Frontend 728 passed, Rust 584 passed (3 ignored)
WIP: Refactor logging to use Logger utility - Phase 1 complete
malibio commentedon Dec 4, 2025
Phase 1 complete - WIP commit pushed (16559da)
Completed:
Remaining:
See commit message for full details: 16559da
Complete logging refactor: Migrate all console.* to Logger utility
Add logging standards to code quality documentation
Refactor logging/debugging approach across codebase (#733)
Refactor logging/debugging approach across codebase (#733)
Refactor logging/debugging approach across codebase (#733)
Refactor logging/debugging approach across codebase (#733)