From 230019eccfb59edb533ae9aac01f3c7ad4c513f3 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 26 Jun 2024 16:08:04 +0200 Subject: [PATCH] feat: add logs for plugins load Co-authored-by: Julien Salleyron --- cmd/traefik/traefik.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cmd/traefik/traefik.go b/cmd/traefik/traefik.go index e373864c1..55eb08a38 100644 --- a/cmd/traefik/traefik.go +++ b/cmd/traefik/traefik.go @@ -46,6 +46,7 @@ import ( "github.com/traefik/traefik/v3/pkg/tracing" "github.com/traefik/traefik/v3/pkg/types" "github.com/traefik/traefik/v3/pkg/version" + "golang.org/x/exp/maps" ) func main() { @@ -224,10 +225,21 @@ func setupServer(staticConfiguration *static.Configuration) (*server.Server, err } // Plugins + pluginLogger := log.Ctx(ctx).With().Logger() + hasPlugins := staticConfiguration.Experimental != nil && (staticConfiguration.Experimental.Plugins != nil || staticConfiguration.Experimental.LocalPlugins != nil) + if hasPlugins { + pluginsList := maps.Keys(staticConfiguration.Experimental.Plugins) + pluginsList = append(pluginsList, maps.Keys(staticConfiguration.Experimental.LocalPlugins)...) + + pluginLogger = pluginLogger.With().Strs("plugins", pluginsList).Logger() + pluginLogger.Info().Msg("Loading plugins...") + } pluginBuilder, err := createPluginBuilder(staticConfiguration) if err != nil { - log.Error().Err(err).Msg("Plugins are disabled because an error has occurred.") + pluginLogger.Err(err).Msg("Plugins are disabled because an error has occurred.") + } else if hasPlugins { + pluginLogger.Info().Msg("Plugins loaded.") } // Providers plugins