Skip to content

Commit

Permalink
chore: replace slog with pterm
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Gelloz committed Dec 14, 2023
1 parent ccb7dc7 commit d6b4c57
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 30 deletions.
19 changes: 17 additions & 2 deletions cmd/logger.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
package main

import (
"github.com/radiofrance/dib/internal/logging"
"github.com/pterm/pterm"
"github.com/spf13/viper"
)

func initLogLevel() {
_ = viper.BindPFlag("log_level", rootCmd.PersistentFlags().Lookup("log-level"))
_ = logging.Init(viper.GetString("log_level"))
logLevel := viper.GetString("log_level")

switch logLevel {
case "debug":
pterm.EnableDebugMessages()
pterm.Debug.Println("debug mode enabled")
case "info", "warning", "error", "fatal":
default:
pterm.Error.Printfln("%q is not a valid loglevel", logLevel)
}

// Customize default info message.
pterm.Info.Prefix = pterm.Prefix{
Text: "INFO",
Style: pterm.NewStyle(pterm.FgBlack, pterm.BgCyan),
}
}
27 changes: 0 additions & 27 deletions internal/logging/logging.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/report/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func RemoveTerminalColors(input []byte) []byte {
return results
}

// StripKanikoBuildLogs Improve readability of kaniko builds logs by removing unwanted stuff from a logrus
// StripKanikoBuildLogs Improve readability of kaniko builds logs by removing unwanted stuff from a
// standard logs message.
func StripKanikoBuildLogs(input []byte) string {
results := patternKanikoLogs.ReplaceAll(input, []byte("$message"))
Expand Down

0 comments on commit d6b4c57

Please sign in to comment.