mirror of
https://github.com/Belphemur/CBZOptimizer.git
synced 2025-10-13 20:18:52 +02:00
fix(logging): fix logging parameter not taken into account
This commit is contained in:
@@ -60,8 +60,14 @@ func init() {
|
||||
"Set log level; can be 'panic', 'fatal', 'error', 'warn', 'info', 'debug', or 'trace'")
|
||||
|
||||
// Add log level environment variable support
|
||||
viper.SetEnvPrefix("")
|
||||
viper.BindEnv("LOG_LEVEL")
|
||||
viper.BindEnv("log", "LOG_LEVEL")
|
||||
viper.BindPFlag("log", rootCmd.PersistentFlags().Lookup("log"))
|
||||
|
||||
rootCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
|
||||
ConfigureLogging()
|
||||
}
|
||||
|
||||
// Ensure the configuration directory exists
|
||||
|
||||
err := os.MkdirAll(configFolder, os.ModePerm)
|
||||
if err != nil {
|
||||
@@ -95,7 +101,7 @@ func ConfigureLogging() {
|
||||
level := zerolog.InfoLevel
|
||||
|
||||
// Check LOG_LEVEL environment variable first
|
||||
envLogLevel := viper.GetString("LOG_LEVEL")
|
||||
envLogLevel := viper.GetString("log")
|
||||
if envLogLevel != "" {
|
||||
if parsedLevel, err := zerolog.ParseLevel(envLogLevel); err == nil {
|
||||
level = parsedLevel
|
||||
|
@@ -13,8 +13,5 @@ var (
|
||||
func main() {
|
||||
commands.SetVersionInfo(version, commit, date)
|
||||
|
||||
// Configure logging before executing commands
|
||||
commands.ConfigureLogging()
|
||||
|
||||
commands.Execute()
|
||||
}
|
||||
|
Reference in New Issue
Block a user