From 3d351c982dca7776ec5c7f7766e1496b6ef84aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Ma=C5=A1ek?= Date: Sat, 15 Feb 2025 23:59:03 +0100 Subject: [PATCH] add log rotation to docker compose --- cmd/debug.go | 16 ++++++++++++---- compose.yaml | 5 +++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/cmd/debug.go b/cmd/debug.go index 9504701..198921b 100644 --- a/cmd/debug.go +++ b/cmd/debug.go @@ -14,15 +14,23 @@ var debugCmd = &cobra.Command{ Short: "Development tools, use with caution", RunE: func(cmd *cobra.Command, args []string) error { logger := logging.Get() - logger.Debugw("Debug message", "foo", 42) - logger.Infow("Info message", "foo", 42) - logger.Warnw("Warn message", "foo", 42) - logger.Errorw("Error message", zap.Error(fmt.Errorf("big bad"))) + repeat, err := cmd.Flags().GetInt("repeat") + if err != nil { + return err + } + for range repeat { + logger.Debugw("Debug message", "foo", 42) + logger.Infow("Info message", "foo", 42) + logger.Warnw("Warn message", "foo", 42) + logger.Errorw("Error message", zap.Error(fmt.Errorf("big bad"))) + } cmd.Println("Done") return nil }, } func init() { + debugCmd.Flags().Int("repeat", 1, "") + rootCmd.AddCommand(debugCmd) } diff --git a/compose.yaml b/compose.yaml index 1222629..b7da480 100644 --- a/compose.yaml +++ b/compose.yaml @@ -15,6 +15,11 @@ services: environment: # Allow insecure TLS if username is "beacon". Remove this in production. - BEACON_EMAIL_TLS_INSECURE=beacon + logging: + driver: "json-file" + options: + max-size: "50m" + max-file: "3" # SMTP server for development and testing. # For production configure your SMTP inside the Beacon config file instead.