Skip to content

Commit

Permalink
refactor: remove deprecated --log.json flag (#613)
Browse files Browse the repository at this point in the history
  • Loading branch information
burningalchemist authored Oct 25, 2024
1 parent 3416f4b commit 373c1a5
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions cmd/sql_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ var (
enableReload = flag.Bool("web.enable-reload", false, "Enable reload collector data handler")
webConfigFile = flag.String("web.config.file", "", "[EXPERIMENTAL] TLS/BasicAuth configuration file path")
configFile = flag.String("config.file", "sql_exporter.yml", "SQL Exporter configuration file path")
logFormatJSON = flag.Bool("log.json", false, "[DEPRECATED] Set log output format to JSON")
logFormat = flag.String("log.format", "logfmt", "Set log output format")
logLevel = flag.String("log.level", "info", "Set log level")
)
Expand Down Expand Up @@ -66,7 +65,7 @@ func main() {
}

// Setup logging.
logger, err := setupLogging(*logLevel, *logFormat, *logFormatJSON)
logger, err := setupLogging(*logLevel, *logFormat)
if err != nil {
fmt.Printf("Error initializing exporter: %s\n", err)
os.Exit(1)
Expand Down Expand Up @@ -152,7 +151,7 @@ func startScrapeErrorsDropTicker(exporter sql_exporter.Exporter, interval model.
}

// setupLogging configures and initializes the logging system.
func setupLogging(logLevel, logFormat string, logFormatJSON bool) (log.Logger, error) {
func setupLogging(logLevel, logFormat string) (log.Logger, error) {
promlogConfig := &promlog.Config{
Level: &promlog.AllowedLevel{},
Format: &promlog.AllowedFormat{},
Expand All @@ -162,13 +161,7 @@ func setupLogging(logLevel, logFormat string, logFormatJSON bool) (log.Logger, e
return nil, err
}

// Override log format if JSON is specified.
finalLogFormat := logFormat
if logFormatJSON {
fmt.Print("Warning: The flag --log.json is deprecated and will be removed in a future release. Please use --log.format=json instead\n")
finalLogFormat = "json"
}
if err := promlogConfig.Format.Set(finalLogFormat); err != nil {
if err := promlogConfig.Format.Set(logFormat); err != nil {
return nil, err
}
// Overriding the default klog with our go-kit klog implementation.
Expand Down

0 comments on commit 373c1a5

Please sign in to comment.