feat: add complete silent mode for TUI applications
- Add silent option to BrainyConfig to suppress ALL console output
- Override console methods (log, info, warn, error) when silent=true
- Add LogLevel.SILENT to Logger for proper silent mode support
- Propagate silent mode to all augmentations automatically
- Update augmentation configs to support silent property
- Restore console methods properly on brain.close()
- Perfect for terminal UI applications that need clean output
Usage:
```javascript
const brain = new Brainy({
storage: { type: 'filesystem', path: './data' },
silent: true // Complete silence - zero console output
})
```
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
4d3e21a0f7
commit
27fb3ef905
6 changed files with 74 additions and 10 deletions
|
|
@ -7,6 +7,7 @@
|
|||
import { isProductionEnvironment, getLogLevel } from './environment.js'
|
||||
|
||||
export enum LogLevel {
|
||||
SILENT = -1, // New: Completely silent mode
|
||||
ERROR = 0,
|
||||
WARN = 1,
|
||||
INFO = 2,
|
||||
|
|
@ -66,7 +67,7 @@ class Logger {
|
|||
// Convert environment log level to Logger LogLevel
|
||||
switch (envLogLevel) {
|
||||
case 'silent':
|
||||
this.config.level = -1 as LogLevel // Below ERROR to silence all logs
|
||||
this.config.level = LogLevel.SILENT
|
||||
break
|
||||
case 'error':
|
||||
this.config.level = LogLevel.ERROR
|
||||
|
|
@ -106,6 +107,11 @@ class Logger {
|
|||
}
|
||||
|
||||
private shouldLog(level: LogLevel, module: string): boolean {
|
||||
// Silent mode - never log anything
|
||||
if (this.config.level === LogLevel.SILENT) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check module-specific level first
|
||||
if (this.config.modules && this.config.modules[module] !== undefined) {
|
||||
return level <= this.config.modules[module]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue