diff --git a/VERSION b/VERSION index 9325c3c..a2268e2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.0 \ No newline at end of file +0.3.1 \ No newline at end of file diff --git a/internal/logging/logging.go b/internal/logging/logging.go index 476dc31..bae4898 100644 --- a/internal/logging/logging.go +++ b/internal/logging/logging.go @@ -41,11 +41,11 @@ func New() *slog.Logger { return slog.New(handler) } -func UpdateLoggerToFile(logger *slog.Logger, filePath string, suffix string) (*slog.Logger, error) { +func UpdateLoggerToFile(logger *slog.Logger, filePath string, suffix string) (*slog.Logger, string, error) { fileLocation := filePath + "anklet" + suffix + ".log" file, err := os.OpenFile(fileLocation, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { - return nil, err + return nil, "", err } options := &slog.HandlerOptions{Level: slog.LevelInfo} @@ -57,7 +57,7 @@ func UpdateLoggerToFile(logger *slog.Logger, filePath string, suffix string) (*s } newLogger := slog.New(handler) - return newLogger, nil + return newLogger, fileLocation, nil } // Handle adds contextual attributes to the Record before calling the underlying diff --git a/main.go b/main.go index 78a3785..f4b4230 100644 --- a/main.go +++ b/main.go @@ -106,11 +106,11 @@ func main() { parentCtx = context.WithValue(parentCtx, config.ContextKey("suffix"), suffix) if loadedConfig.Log.FileDir != "" { - logger.InfoContext(parentCtx, "updating logger to file", slog.String("fileDir", loadedConfig.Log.FileDir)) - logger, err = logging.UpdateLoggerToFile(logger, loadedConfig.Log.FileDir, suffix) + logger, fileLocation, err := logging.UpdateLoggerToFile(logger, loadedConfig.Log.FileDir, suffix) if err != nil { logger.ErrorContext(parentCtx, "error updating logger to file", "error", err) } + logger.InfoContext(parentCtx, "writing logs to file", slog.String("fileLocation", fileLocation)) logger.InfoContext(parentCtx, "loaded config", slog.Any("config", loadedConfig)) }