Skip to content

File path for source field is calculated from CWD, which only works in original project folder #16

@ansel1

Description

@ansel1

If AddSource=true, the source field in the log is a relative file name, relative to the current working directory. That does work ok when this handler is used in code being run from a go project, as the go source files are typically relative to the project's root folder, and that's typically also going to be the CWD when the project is run.

But if the executable is run from a different location (like if it is packaged in a docker container), when the working directory is going to be unrelated to the source file location. You end up with log entries like:

../../../../Users/regan/dev/sallyportflumev2/sallyport/cmd/sallyport/main.go:49

What would be ideal is to always calculate the relative path against the root of the go module that particular source file originally came from, but I'm not sure that's possible.

I don't have a suggestion for an alternative yet. I'll think about it. I think other projects just show the filename with no path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions