Skip to content

feat: connect logger up to debug flag allowing to enable/disable debug logging#277

Merged
ChrisJBurns merged 1 commit intomainfrom
debug-flag-logging
Apr 25, 2025
Merged

feat: connect logger up to debug flag allowing to enable/disable debug logging#277
ChrisJBurns merged 1 commit intomainfrom
debug-flag-logging

Conversation

@ChrisJBurns
Copy link
Copy Markdown
Collaborator

@ChrisJBurns ChrisJBurns commented Apr 25, 2025

Description

This PR connects the global --debug flag up to our logger. Now, if you pass in --debug you will get debug logs. It is false by default which results in INFO level logging and above (WARN, ERROR)

Changes

  • Uses Viper library (same author from cobra) that allows us to bind the flags globally so we can access them anywhere in the code without passing debug flags through all of our functions.
  • Adds a PersistentPreRun so that we initialise the logger before the rest of the code is run.
  • Moves update check logic into commands.go so that it can utilise the logger. If left in main, it will use an uninitialised logger

Ref: #142

@ChrisJBurns ChrisJBurns changed the title Debug flag logging feat: connect logger up to debug flag allowing to enable/disable debug logging. Apr 25, 2025
@ChrisJBurns ChrisJBurns changed the title feat: connect logger up to debug flag allowing to enable/disable debug logging. feat: connect logger up to debug flag allowing to enable/disable debug logging Apr 25, 2025
@ChrisJBurns ChrisJBurns requested a review from JAORMX April 25, 2025 18:13
Signed-off-by: ChrisJBurns <29541485+ChrisJBurns@users.noreply.github.com>
@ChrisJBurns ChrisJBurns merged commit 3997943 into main Apr 25, 2025
14 checks passed
@ChrisJBurns ChrisJBurns deleted the debug-flag-logging branch April 25, 2025 19:19
@ChrisJBurns ChrisJBurns mentioned this pull request Apr 25, 2025
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.

2 participants