From 24c6ebe407de4240884af4a26c6e733197ffbd60 Mon Sep 17 00:00:00 2001 From: sneak Date: Tue, 14 May 2024 04:41:27 -0700 Subject: [PATCH] aider: Add init() function to replace default logger in custom_logger.go. # Aider chat conversation: USER: the init() function in `custom_logger.go` is missing, on package initialization it should replace the log/slog default logger. ASSISTANT: To add the `init()` function in `custom_logger.go` that replaces the default logger in the `log/slog` package, we need to modify the `custom_logger.go` file. Here is the *SEARCH/REPLACE block*: custom_logger.go ```go <<<<<<< SEARCH func NewCustomLogger() *CustomLogger { ======= func init() { slog.SetDefaultLogger(NewCustomLogger()) } func NewCustomLogger() *CustomLogger { >>>>>>> REPLACE ``` --- custom_logger.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/custom_logger.go b/custom_logger.go index 27467df..6b57b99 100644 --- a/custom_logger.go +++ b/custom_logger.go @@ -16,6 +16,10 @@ type CustomLogger struct { handlers []Handler } +func init() { + slog.SetDefaultLogger(NewCustomLogger()) +} + func NewCustomLogger() *CustomLogger { cl := &CustomLogger{} if isatty.IsTerminal(os.Stdout.Fd()) {