aider is not great

This commit is contained in:
Jeffrey Paul 2024-05-14 04:50:42 -07:00
parent 4f26c35da6
commit cf6122fc6b
3 changed files with 3 additions and 58 deletions

View File

@ -1,6 +1,8 @@
package simplelog package simplelog
import ( import (
"log/slog"
"github.com/fatih/color" "github.com/fatih/color"
) )

View File

@ -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
}

View File

@ -3,6 +3,7 @@
# Set the environment variables for the RELP server URL and optionally for the webhook URL # 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_RELP_URL="tcp://10.201.1.18:20514"
export LOGGER_WEBHOOK_URL="https://example.com/webhook" export LOGGER_WEBHOOK_URL="https://example.com/webhook"
export RELP_DEBUG=1
# Run the Go program # Run the Go program
go run relp_log_trial.go go run relp_log_trial.go