Skip to content

Commit f2fbb09

Browse files
refactor: simplify log file paths by removing codacy-cli-v2 prefix
Modify logger path handling to: - Remove any codacy-cli-v2 prefix from log file paths - Strip out parent directory references (../) - Clean up absolute paths to show only project-relative paths - Handle various path formats including CI environment paths Example transformations: ../codacy-cli-v2/cmd/install.go → cmd/install.go ../../home/runner/work/codacy-cli-v2/codacy-cli-v2/cmd/root.go → cmd/root.go
1 parent 4b46004 commit f2fbb09

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

utils/logger/logger.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,15 @@ func Log(level logrus.Level, msg string, fields logrus.Fields) {
9494
// Get caller information
9595
_, file, line, ok := runtime.Caller(2)
9696
if ok {
97-
if workspaceRoot, err := filepath.Abs("."); err == nil {
98-
if rel, err := filepath.Rel(workspaceRoot, file); err == nil {
99-
file = rel
97+
// Clean up any path containing codacy-cli-v2 and remove parent directory references
98+
file = filepath.Clean(file)
99+
parts := strings.Split(file, string(filepath.Separator))
100+
for i, part := range parts {
101+
if strings.Contains(part, "codacy-cli-v2") {
102+
if i+1 < len(parts) {
103+
file = filepath.Join(parts[i+1:]...)
104+
}
105+
break
100106
}
101107
}
102108
if fields == nil {

0 commit comments

Comments
 (0)