Skip to content

Commit 170b79c

Browse files
committed
Fix debug log format
1 parent 9f24720 commit 170b79c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/logger/logger.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"log/slog"
1212
"os"
1313
"path"
14+
"path/filepath"
1415
"strconv"
1516
"strings"
1617

@@ -55,8 +56,9 @@ func New(logPath, level string) *slog.Logger {
5556
if a.Key == slog.SourceKey {
5657
source, ok := a.Value.Any().(*slog.Source)
5758
if ok {
58-
relativeFilePath := strings.Split(source.File, "/agent/")[1]
59-
a.Value = slog.StringValue(relativeFilePath + ":" + strconv.Itoa(source.Line))
59+
directory := filepath.Dir(source.File)
60+
relativePath := path.Join(filepath.Base(directory), filepath.Base(source.File))
61+
a.Value = slog.StringValue(relativePath + ":" + strconv.Itoa(source.Line))
6062
}
6163
}
6264

0 commit comments

Comments
 (0)