Skip to content

fix: suppress info-level debug logging in CLI commands#29

Merged
ggulpari merged 2 commits intomainfrom
claude/remove-debug-logging-01TsUCCVLMSCTV2ssrPPHVJv
Nov 17, 2025
Merged

fix: suppress info-level debug logging in CLI commands#29
ggulpari merged 2 commits intomainfrom
claude/remove-debug-logging-01TsUCCVLMSCTV2ssrPPHVJv

Conversation

@Slashmsu
Copy link
Copy Markdown
Collaborator

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.

🎉 Pull Request

Description

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality
    to not work as expected)
  • 📚 Documentation update
  • 🔧 Configuration/build changes
  • ✅ Test improvements
  • ♻️ Code refactoring (no functional changes)

Related Issue

Fixes #(issue number)

Changes Made

Testing

  • All existing tests pass (npm test)
  • Added new tests for the changes
  • Tested manually with examples
  • Linting passes (npm run lint)
  • Type checking passes (npm run type-check)

Checklist

  • My code follows the project's code style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

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:


Thank you for contributing to SomonScript! 🚀

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.
@Slashmsu Slashmsu self-assigned this Nov 17, 2025
@Slashmsu Slashmsu requested a review from ggulpari November 17, 2025 14:23
ggulpari
ggulpari previously approved these changes Nov 17, 2025
@github-actions
Copy link
Copy Markdown

✅ Tests completed on Node.js 20.x: success

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines 355 to +356
private static readonly globalConfig: Partial<LoggerConfig> = {
level: 'info',
format: 'json',
level: (process.env.LOG_LEVEL as LogLevel) || 'warn',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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.
@sonarqubecloud
Copy link
Copy Markdown

@ggulpari ggulpari self-requested a review November 17, 2025 14:35
@github-actions
Copy link
Copy Markdown

✅ Tests completed on Node.js 20.x: success

@ggulpari ggulpari merged commit 92874d5 into main Nov 17, 2025
7 checks passed
@ggulpari ggulpari deleted the claude/remove-debug-logging-01TsUCCVLMSCTV2ssrPPHVJv branch November 17, 2025 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants