uber-go / zap

Blazing fast, structured, leveled logging in Go.
https://pkg.go.dev/go.uber.org/zap
MIT License
22.1k stars 1.44k forks source link

EntryCaller output path is too long or too short #1457

Open zlx2019 opened 3 months ago

zlx2019 commented 3 months ago

Is it possible to make the EntryCaller output path relative to the project? Wrong example: D:/xxx/xxx/app/app.go:46 app/app.go:46

What I want is this:

/cmd/app/app.go:46 /.../internal/server/server.go:46
zlx2019 commented 3 months ago

Does this help IDEA link jump to where the output log is

r-hang commented 3 months ago

Hey @zlx2019, could you clarify what you mean by project root and how it could be calculated by zap? Is the benefit of this suggestion to help with IDE integration?

zlx2019 commented 3 months ago

Hey @zlx2019, could you clarify what you mean by project root and how it could be calculated by zap? Is the benefit of this suggestion to help with IDE integration?

Enter the relative path of the log source file to the project, which will help you click the link in GoLand to jump to the output.

r-hang commented 2 months ago

How do we know what the project root is? Is that based on the the IDE? If that's the case, I don't believe it's best to encode IDE specific details into Zap.