common: fix unclosed logrus logging pipes

This commit is contained in:
Lukas Zapletal 2025-05-22 13:44:42 +02:00 committed by Lukáš Zapletal
parent 0c325137cf
commit 1cde7e341b
4 changed files with 67 additions and 36 deletions

View file

@ -80,10 +80,12 @@ func main() {
}
logrus.Info("Loaded configuration:")
err = DumpConfig(*config, logrus.StandardLogger().WriterLevel(logrus.InfoLevel))
dumpWriter := logrus.StandardLogger().WriterLevel(logrus.DebugLevel)
err = DumpConfig(*config, dumpWriter)
if err != nil {
logrus.Fatalf("Error printing configuration: %v", err)
}
dumpWriter.Close()
if config.DeploymentChannel != "" {
logrus.AddHook(&slogger.EnvironmentHook{Channel: config.DeploymentChannel})

View file

@ -190,11 +190,13 @@ var run = func() {
}
logrus.Info("Composer configuration:")
encoder := toml.NewEncoder(logrus.StandardLogger().WriterLevel(logrus.InfoLevel))
configWriter := logrus.StandardLogger().WriterLevel(logrus.DebugLevel)
encoder := toml.NewEncoder(configWriter)
err = encoder.Encode(&config)
if err != nil {
logrus.Fatalf("Could not print config: %v", err)
}
configWriter.Close()
if config.DeploymentChannel != "" {
logrus.AddHook(&slogger.EnvironmentHook{Channel: config.DeploymentChannel})