From 0bb2cf9a080d65cb8319a7bde4017fd6f177629d Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Tue, 7 Feb 2023 02:23:04 +0400 Subject: [PATCH] Removed log-stdout flag. Ditched self-made logging. --- cmd/dwelling-radio/main.go | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/cmd/dwelling-radio/main.go b/cmd/dwelling-radio/main.go index e696a3d..6982a90 100644 --- a/cmd/dwelling-radio/main.go +++ b/cmd/dwelling-radio/main.go @@ -18,7 +18,6 @@ import ( var version string var configPath *string = flag.String("conf", "config.yaml", "path to configuration file") -var logToStdout *bool = flag.Bool("log-stdout", false, "write logs to stdout") var noLiquidsoap *bool = flag.Bool("no-liquidsoap", false, "don't run liquidsoap") var showVersion *bool = flag.Bool("v", false, "show version") @@ -35,8 +34,6 @@ func main() { log.Fatalln(err) } - if *logToStdout { - config.Log.ToStdout = true } defer func() { @@ -45,15 +42,10 @@ func main() { } }() - logErr, err := logging.NewLogger(config.Log.Error, config.Log.ToStdout) - if err != nil { - log.Fatalln("error logger:", err) - } - defer logErr.Close() playlistWatcher := radio.NewPlaylistLogWatcher() if err := playlistWatcher.Watch(config.Icecast.Playlist, config.ListLastNSongs); err != nil { - logErr.Fatalln(err) + log.Fatalln(err) } defer playlistWatcher.Close() @@ -69,40 +61,28 @@ func main() { if !*noLiquidsoap { liquid, err := radio.NewLiquidsoap(config.Liquidsoap.ExecPath, config.Liquidsoap.ScriptPath) if err != nil { - logErr.Fatalln("liquidsoap:", err) + log.Fatalln("liquidsoap:", err) } defer func() { if err := liquid.Stop(); err != nil { if !errors.Is(err, radio.ErrLiquidsoapNotRunning) { - logErr.Println(err) + log.Println(err) } } }() } if err := srv.Start(config.SplitNetworkAddress()); err != nil { - logErr.Fatalln(err) + log.Fatalln(err) } - logReload := make(chan os.Signal, 1) - signal.Notify(logReload, syscall.SIGHUP) - - go func() { - for { - select { - case <-logReload: - logErr.Reopen(config.Log.Error) - } - } - }() - doneSignal := make(chan os.Signal, 1) signal.Notify(doneSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) <-doneSignal if err := srv.Stop(); err != nil { - logErr.Fatalln(err) + log.Fatalln(err) } }