Skip to content

Commit

Permalink
Refactor main.go file in terms of logging (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuskoman authored Sep 19, 2023
1 parent 2f652fd commit b413ac4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cmd/exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"log"
"os"

"github.com/joho/godotenv"
"github.com/kuskoman/logstash-exporter/collectors"
Expand All @@ -23,21 +24,20 @@ func main() {
}
slog.SetDefault(logger)

port := config.Port
host := config.Host
port, host := config.Port, config.Host
logstashUrl := config.LogstashUrl

slog.Debug("Application starting... ")
slog.Debug("application starting... ")
versionInfo := config.GetVersionInfo()
slog.Info(versionInfo.String())

collectorManager := collectors.NewCollectorManager(logstashUrl)
server := server.NewAppServer(host, port)
appServer := server.NewAppServer(host, port)
prometheus.MustRegister(collectorManager)

slog.Info("Starting server on port", "port", port)
err = server.ListenAndServe()
if err != nil {
slog.Info("starting server on", "host", host, "port", port)
if err := appServer.ListenAndServe(); err != nil {
slog.Error("failed to listen and serve", "err", err)
os.Exit(1)
}
}

0 comments on commit b413ac4

Please sign in to comment.