fix: suppress info-level debug logging in CLI commands#29
Conversation
Changed default log level from 'info' to 'warn' to prevent verbose
module loader logs from appearing in normal CLI usage (compile, run).
Key changes:
- Default log level: 'info' → 'warn' (only show warnings/errors)
- Default format: 'json' → 'pretty' (better for CLI)
- Added LOG_LEVEL environment variable support
- Added LOG_FORMAT environment variable support
Users can still enable debug logs when needed:
LOG_LEVEL=info somon run file.som
LOG_LEVEL=debug LOG_FORMAT=json somon compile file.som
Fixes issue where module loader was outputting JSON logs like:
{"timestamp":"...","level":"info","message":"Module loaded successfully",...}
Now 'somon run' produces clean output by default.
|
✅ Tests completed on Node.js 20.x: success |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| private static readonly globalConfig: Partial<LoggerConfig> = { | ||
| level: 'info', | ||
| format: 'json', | ||
| level: (process.env.LOG_LEVEL as LogLevel) || 'warn', |
There was a problem hiding this comment.
Validate LOG_LEVEL env to avoid suppressing all logs
LoggerFactory now assigns level from process.env.LOG_LEVEL without validation; when the env var is set to a common uppercase or invalid value (e.g. LOG_LEVEL=INFO), this.config.level no longer matches the lowercase keys used in shouldLog, so Logger.LOG_LEVELS[this.config.level] is undefined and every log call is skipped—including warnings and errors. This regression only appears in environments with a non‑lowercase LOG_LEVEL and effectively disables logging instead of falling back to warn or rejecting the bad value.
Useful? React with 👍 / 👎.
The ternary expression already narrows the type to 'json' | 'pretty', so the type assertion is redundant.
|
|
✅ Tests completed on Node.js 20.x: success |



Changed default log level from 'info' to 'warn' to prevent verbose module loader logs from appearing in normal CLI usage (compile, run).
Key changes:
Users can still enable debug logs when needed:
LOG_LEVEL=info somon run file.som LOG_LEVEL=debug LOG_FORMAT=json somon compile file.som
Fixes issue where module loader was outputting JSON logs like: {"timestamp":"...","level":"info","message":"Module loaded successfully",...}
Now 'somon run' produces clean output by default.
🎉 Pull Request
Description
Type of Change
to not work as expected)
Related Issue
Fixes #(issue number)
Changes Made
Testing
npm test)npm run lint)npm run type-check)Checklist
Additional Context
📋 License Information
SomonScript is open source software licensed under the MIT License.
By submitting this pull request, you agree that your contributions will be
licensed under the MIT License.
For contribution guidelines, please review:
guidelines
Thank you for contributing to SomonScript! 🚀