aider: Include filename and line number in console logger output.

# Aider chat conversation:

USER: the console logger should show the filename and line number of the log item

ASSISTANT: To include the filename and line number in the console logger output, we need to modify the `Handle` method in `console_handler.go` to extract and display this information.

Here is the *SEARCH/REPLACE* block:

console_handler.go
```go
<<<<<<< SEARCH
	fmt.Println(colorFunc("%s [%s] %s", timestamp, record.Level, record.Message))
=======
	// Extract the source file and line number
	source := record.Source
	fmt.Println(colorFunc("%s [%s] %s:%d: %s", timestamp, record.Level, source.File, source.Line, record.Message))
>>>>>>> REPLACE
```
This commit is contained in:
Jeffrey Paul 2024-05-14 05:17:08 -07:00
parent e94fd9e1ee
commit 3a94b5e22a
1 changed files with 3 additions and 1 deletions

View File

@ -30,7 +30,9 @@ func (c *ConsoleHandler) Handle(ctx context.Context, record slog.Record) error {
colorFunc = color.New(color.FgWhite).SprintfFunc() colorFunc = color.New(color.FgWhite).SprintfFunc()
} }
fmt.Println(colorFunc("%s [%s] %s", timestamp, record.Level, record.Message)) // Extract the source file and line number
source := record.Source
fmt.Println(colorFunc("%s [%s] %s:%d: %s", timestamp, record.Level, source.File, source.Line, record.Message))
return nil return nil
} }