openhue-cli icon indicating copy to clipboard operation
openhue-cli copied to clipboard

set the log level from the config file

Open pantelm opened this issue 2 months ago β€’ 1 comments

I use openhue-cli inside a script for polybar and I have lots of accessories that are not lights so the log is growing to much.

With this simple change, the user can choose the log level he want from the config file Log levels are strings from Logrus

Summary by CodeRabbit

  • New Features
    • Added configurable log level support β€” the app now reads and applies a user-specified logging verbosity at startup.
  • Bug Fixes
    • Logging now respects the configured level instead of using a fixed default; invalid log level values will cause startup to fail so issues are surfaced immediately.

pantelm avatar Nov 16 '25 09:11 pantelm

Walkthrough

Config gains a new LogLevel field and the logger Init function now accepts and applies a log level from configuration; logger initialization reads and parses that level and sets the logger accordingly, fatalling on parse error.

Changes

Cohort / File(s) Summary
Configuration & Logger
openhue/config.go, util/logger/logger.go
Added LogLevel string to Config; changed Init(path string) β†’ Init(path string, level string); logger now parses level with log.ParseLevel and sets log.SetLevel(logLevel); parse errors call log.Fatal(err).

Sequence Diagram

sequenceDiagram
    participant Config
    participant Logger as Logger.Init
    participant LogLib as log package

    Config->>Config: load config file
    Config->>Config: read `LogLevel`
    Config->>Logger: Init(path, LogLevel)
    alt parse succeeds
        Logger->>LogLib: ParseLevel(level)
        Logger->>LogLib: SetLevel(parsedLevel)
        Logger->>LogLib: SetOutput(file)
    else parse fails
        Logger->>Logger: Fatal(error)
    end

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check callers of util/logger.Init for updated signature usage.
  • Confirm fatal-on-parse behavior is intentional (unreachable assignment after log.Fatal).
  • Verify tests or startup paths handle missing/invalid LogLevel values and that defaulting behavior (if desired) is handled elsewhere.

Poem

πŸ‡ In burrows of code I hop and peep,

I tweak the logs so wakes not sleep.
A level added, crisp and bright,
Now bunnies whisper or roar by night. πŸ₯•

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
βœ… Passed checks (2 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title clearly and concisely summarizes the main change: allowing users to set the log level from the configuration file, which is the primary objective of the PR.
✨ Finishing touches
  • [ ] πŸ“ Generate docstrings
πŸ§ͺ Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

πŸ“œ Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 6f76573bd0b8178a6ed1dfaa9807b6aaad10c642 and f058751852ececb24180aeea365d5189e49f8c4c.

πŸ“’ Files selected for processing (1)
  • util/logger/logger.go (1 hunks)
πŸ”‡ Additional comments (1)
util/logger/logger.go (1)

8-8: Function signature updated to accept log level parameter.

The addition of the level parameter enables configurable log levels from the configuration file, which aligns well with the PR objectives.


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 and usage tips.

coderabbitai[bot] avatar Nov 16 '25 09:11 coderabbitai[bot]