diff --git a/cmd/birthdaybot/main.go b/cmd/birthdaybot/main.go index ddf5439..63345cf 100644 --- a/cmd/birthdaybot/main.go +++ b/cmd/birthdaybot/main.go @@ -2,6 +2,7 @@ package main import ( "flag" + "fmt" "os" "os/signal" "syscall" @@ -11,35 +12,32 @@ import ( "github.com/charmbracelet/log" ) -func configureLogger(config *model.Config, logger *log.Logger) { +func loggerFromConfig(config *model.Config) *log.Logger { // ToDo: apply config to logger + return log.New(os.Stderr) } func main() { configFlag := flag.String("config", "birthdaybot.yml", "path to the configuration file") flag.Parse() - logger := log.New(os.Stderr) - config, err := model.ReadConfig(*configFlag) if err != nil { - logger.Error("error reading config", "configPath", *configFlag, "error", err) + fmt.Fprintf(os.Stderr, "ERROR: error reading config %q: %s\n", *configFlag, err) os.Exit(1) } if err := config.IsValid(); err != nil { - logger.Error("invalid config", "configPath", *configFlag, "error", err) + fmt.Fprintf(os.Stderr, "ERROR: invalid config %q: %s\n", *configFlag, err) os.Exit(1) } - configureLogger(config, logger) - srv, err := server.New( - server.WithLogger(logger), + server.WithLogger(loggerFromConfig(config)), server.WithConfig(config), ) if err != nil { - logger.Error("error creating server", "error", err) + fmt.Fprintf(os.Stderr, "ERROR: error creating server: %s\n", err) os.Exit(1) }