aider: Renamed CustomLogger to CustomHandler.
# Aider chat conversation: USER: rename CustomLogger to CustomHandler ASSISTANT: To make this change we need to modify `simplelog.go`: 1. Replace all instances of `CustomLogger` with `CustomHandler`. Here are the *SEARCH/REPLACE* blocks: simplelog.go ```go <<<<<<< SEARCH 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{} ======= type CustomHandler struct { handlers []slog.Handler } func (cl *CustomHandler) 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 = NewCustomHandler() slog.SetDefault(ourCustomLogger) } func NewCustomHandler() *CustomHandler { cl := &CustomHandler{} >>>>>>> REPLACE ```
This commit is contained in:
parent
373dd0ac76
commit
4f26c35da6
10
simplelog.go
10
simplelog.go
@ -13,11 +13,11 @@ var (
|
||||
webhookURL = os.Getenv("LOGGER_WEBHOOK_URL")
|
||||
)
|
||||
|
||||
type CustomLogger struct {
|
||||
type CustomHandler struct {
|
||||
handlers []slog.Handler
|
||||
}
|
||||
|
||||
func (cl *CustomLogger) Log(level slog.Level, message string, data ...slog.Field) error {
|
||||
func (cl *CustomHandler) 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
|
||||
@ -29,12 +29,12 @@ func (cl *CustomLogger) Log(level slog.Level, message string, data ...slog.Field
|
||||
var ourCustomLogger *slog.Logger
|
||||
|
||||
func init() {
|
||||
ourCustomLogger = NewCustomLogger()
|
||||
ourCustomLogger = NewCustomHandler()
|
||||
slog.SetDefault(ourCustomLogger)
|
||||
}
|
||||
|
||||
func NewCustomLogger() *CustomLogger {
|
||||
cl := &CustomLogger{}
|
||||
func NewCustomHandler() *CustomHandler {
|
||||
cl := &CustomHandler{}
|
||||
if isatty.IsTerminal(os.Stdout.Fd()) {
|
||||
cl.handlers = append(cl.handlers, NewConsoleHandler())
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user