From cf6122fc6b4830f10875f4618ebb15f6e6bca3de Mon Sep 17 00:00:00 2001 From: sneak Date: Tue, 14 May 2024 04:50:42 -0700 Subject: [PATCH] aider is not great --- console_handler.go | 2 ++ custom_logger.go | 58 ------------------------------------- tools/run_relp_log_trial.sh | 1 + 3 files changed, 3 insertions(+), 58 deletions(-) delete mode 100644 custom_logger.go diff --git a/console_handler.go b/console_handler.go index 913b54d..59f8b57 100644 --- a/console_handler.go +++ b/console_handler.go @@ -1,6 +1,8 @@ package simplelog import ( + "log/slog" + "github.com/fatih/color" ) diff --git a/custom_logger.go b/custom_logger.go deleted file mode 100644 index 9843e96..0000000 --- a/custom_logger.go +++ /dev/null @@ -1,58 +0,0 @@ -package simplelog - -import ( - "log" - "log/slog" - "os" - - "github.com/mattn/go-isatty" -) - -var ( - relpServerURL = os.Getenv("LOGGER_RELP_URL") - webhookURL = os.Getenv("LOGGER_WEBHOOK_URL") -) - -type CustomLogger struct { - handlers []slog.Handler -} - -func (cl *CustomLogger) Log(level slog.Level, message string, data ...slog.Field) error { - for _, handler := range cl.handlers { - if err := handler.Log(level, message, data...); err != nil { - return err - } - } - return nil -} - -var ourCustomLogger *slog.Logger - -func init() { - ourCustomLogger = NewCustomLogger() - slog.SetDefault(ourCustomLogger) -} - -func NewCustomLogger() *CustomLogger { - cl := &CustomLogger{} - if isatty.IsTerminal(os.Stdout.Fd()) { - cl.handlers = append(cl.handlers, NewConsoleHandler()) - } else { - cl.handlers = append(cl.handlers, NewJSONHandler()) - } - if relpServerURL != "" { - handler, err := NewRELPHandler(relpServerURL) - if err != nil { - log.Fatalf("Failed to initialize RELP handler: %v", err) - } - cl.handlers = append(cl.handlers, handler) - } - if webhookURL != "" { - handler, err := NewWebhookHandler(webhookURL) - if err != nil { - log.Fatalf("Failed to initialize Webhook handler: %v", err) - } - cl.handlers = append(cl.handlers, handler) - } - return cl -} diff --git a/tools/run_relp_log_trial.sh b/tools/run_relp_log_trial.sh index bd28de8..98f48c3 100755 --- a/tools/run_relp_log_trial.sh +++ b/tools/run_relp_log_trial.sh @@ -3,6 +3,7 @@ # Set the environment variables for the RELP server URL and optionally for the webhook URL export LOGGER_RELP_URL="tcp://10.201.1.18:20514" export LOGGER_WEBHOOK_URL="https://example.com/webhook" +export RELP_DEBUG=1 # Run the Go program go run relp_log_trial.go