Skip to content

fix: config log level - #209

Merged
thushan merged 3 commits into
mainfrom
fix/config-log-level
Aug 5, 2026
Merged

fix: config log level#209
thushan merged 3 commits into
mainfrom
fix/config-log-level

Conversation

@thushan

@thushan thushan commented Aug 5, 2026

Copy link
Copy Markdown
Owner

wires logging.level from config.yaml to the runtime logger (previously parsed but ignored); precedence is OLLA_LOGGING_LEVEL env > config file > default, invalid values warn and fall back rather than crash; also moves flag.Parse() out of init(), fixing go test on the main package.

Summary by CodeRabbit

  • New Features

    • Logging levels can now be configured and applied at runtime.
    • Supported log levels are validated case-insensitively.
  • Bug Fixes

    • Invalid or empty logging settings now safely fall back to the default level.
    • Test commands no longer process application command-line flags unexpectedly.
    • Logging remains available if applying a configured level fails.

thushan added 3 commits August 5, 2026 21:50
The bootstrap logger only ever read OLLA_LOG_LEVEL, so logging.level in
config.yaml was parsed but silently ignored. Rebuild the logger after
config load using the file's level (with OLLA_LOGGING_LEVEL still able
to override it, as config.Load already applies), falling back to the
default with a warning on an invalid value rather than crashing.

Also moved flag.Parse out of init() into main() - calling it at package
init time breaks go test for the main package, which is what surfaced
once a _test.go file was added here.
@thushan thushan self-assigned this Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8122e75c-166f-45ba-92ef-2eae0393f4fa

📥 Commits

Reviewing files that changed from the base of the PR and between 6e51ca0 and 67cb383.

📒 Files selected for processing (4)
  • internal/logger/logger.go
  • internal/logger/logger_test.go
  • main.go
  • main_test.go

Walkthrough

The change adds case-insensitive log-level validation, defers flag parsing until main, and resolves the configured runtime log level after configuration loading. The application replaces the bootstrap logger when required and retains it if replacement fails.

Changes

Runtime logging

Layer / File(s) Summary
Log-level validation
internal/logger/logger.go, internal/logger/logger_test.go
Adds IsValidLevel for supported level names and tests valid, case-insensitive, empty, and unsupported values.
Startup initialisation
main.go
Moves flag parsing into main and manages bootstrap logger cleanup through a replaceable handle.
Runtime logger resolution
main.go, main_test.go
Resolves configured levels after configuration loading, warns for invalid values, replaces the logger when needed, and tests valid, empty, and invalid configurations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant main
  participant Configuration
  participant resolveRuntimeLogLevel
  participant IsValidLevel
  participant RuntimeLogger
  main->>Configuration: load configuration
  main->>resolveRuntimeLogLevel: resolve configured level
  resolveRuntimeLogLevel->>IsValidLevel: validate level
  IsValidLevel-->>resolveRuntimeLogLevel: return validity
  resolveRuntimeLogLevel-->>main: return effective level
  main->>RuntimeLogger: rebuild when level differs
  RuntimeLogger-->>main: return logger and cleanup handle
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the primary change: fixing configuration-based log-level handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/config-log-level

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thushan thushan changed the title Fix/config log level fix: config log level Aug 5, 2026
@thushan

thushan commented Aug 5, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@thushan
thushan merged commit 5e27c11 into main Aug 5, 2026
6 checks passed
@thushan
thushan deleted the fix/config-log-level branch August 5, 2026 22:09
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.

1 participant