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
Copy file name to clipboardExpand all lines: cli/knowledge.md
+113Lines changed: 113 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -671,3 +671,116 @@ When implementing automatic retry on reconnection, scheduling retries in both SD
671
671
- Network failures with pending operations
672
672
- Error cascades
673
673
- Rapid state transitions
674
+
675
+
## Logging Strategy and Best Practices
676
+
677
+
The CLI uses Pino for structured logging with multiple severity levels. Proper log level selection is critical for debugging without creating noise in production.
678
+
679
+
### Log Levels
680
+
681
+
1. **debug** - Detailed diagnostic information for troubleshooting
682
+
- Connection state changes (initial connection, reconnection, disconnection)
683
+
- Retry scheduling and execution
684
+
- State transitions and effect triggers
685
+
- Internal operation details
686
+
- **Use when**: Information is only needed for debugging specific issues
687
+
688
+
2. **info** - General informational messages about normal operations
689
+
- User-initiated actions completing successfully
690
+
- Significant application state changes visible to users
691
+
- Major workflow milestones
692
+
- **Use when**: Information is useful for understanding normal application flow
693
+
694
+
3. **warn** - Potentially harmful situations that don't prevent operation
695
+
- Deprecated API usage
696
+
- Approaching retry limits
697
+
- Degraded functionality
698
+
- Recoverable errors
699
+
- **Use when**: Something unexpected happened but the application can continue
700
+
701
+
4. **error** - Error events that might still allow the application to continue
702
+
- Failed API calls
703
+
- Failed message sends
704
+
- Validation errors
705
+
- **Use when**: An operation failed but the application remains functional
706
+
707
+
5. **fatal** - Severe errors that cause the application to abort
708
+
- Unrecoverable crashes
709
+
- Critical resource failures
710
+
- **Use when**: The application must terminate
711
+
712
+
### Best Practices
713
+
714
+
1. **Avoid Verbose Logging in Hot Paths**
715
+
- Connection/reconnection events should use `debug` level
716
+
- Frequent state updates should use `debug` level
717
+
- Only log user-facing actions at `info` level
718
+
719
+
2. **Structured Logging**
720
+
- Always include context data as the first parameter
0 commit comments