Browse Source

Fix loading log configs from local files and secret managers

DarthSim 7 months ago
parent
commit
7f4c099027
3 changed files with 15 additions and 4 deletions
  1. 4 0
      CHANGELOG.md
  2. 7 0
      logger/log.go
  3. 4 4
      main.go

+ 4 - 0
CHANGELOG.md

@@ -1,5 +1,9 @@
 # Changelog
 
+## [Unreleased]
+### Fix
+- Fix loading log configs from local files and secret managers.
+
 ## [3.26.0] - 2024-09-16
 # Add
 - Add `imgproxy.source_image_url` and `imgproxy.processing_options` attributes to New Relic, DataDog, and OpenTelemetry traces.

+ 7 - 0
logger/log.go

@@ -9,6 +9,13 @@ import (
 	"github.com/imgproxy/imgproxy/v3/config/configurators"
 )
 
+func init() {
+	// Configure logrus so it can be used before Init().
+	// Structured formatter is a compromise between JSON and pretty formatters.
+	logrus.SetOutput(os.Stdout)
+	logrus.SetFormatter(&structuredFormatter{})
+}
+
 func Init() error {
 	logrus.SetOutput(os.Stdout)
 

+ 4 - 4
main.go

@@ -28,6 +28,10 @@ import (
 )
 
 func initialize() error {
+	if err := loadenv.Load(); err != nil {
+		return err
+	}
+
 	if err := logger.Init(); err != nil {
 		return err
 	}
@@ -36,10 +40,6 @@ func initialize() error {
 
 	maxprocs.Set(maxprocs.Logger(log.Debugf))
 
-	if err := loadenv.Load(); err != nil {
-		return err
-	}
-
 	if err := config.Configure(); err != nil {
 		return err
 	}