Logrus: Limiting the information printed when SetReportCaller is true

Created on 19 Nov 2018  路  3Comments  路  Source: sirupsen/logrus

When SetReportCaller is true, the log has the full file path (starting at root) and then also the method name as below
INFO[2018-11-19 10:15:34]/Users/anoop/goworkspace/src/go-sample-app/pack/some_doer.go:22 go-sample-app/pack.DoSomething() Doing something

Is it possible to restrict the file name to start only from the application's root directory and not print the method name? Below is an example of what I am looking for.
INFO[2018-11-19 10:15:34]go-sample-app/pack/some_doer.go:22 Doing something

enhancement

Most helpful comment

You can partially get rid of the path by passing trimpath flags to go build:

go build \
    -gcflags="all=-trimpath=${GOPATH}" \
    -asmflags "all=-trimpath=${GOPATH}" \
    ./...

All 3 comments

At this time the current implementation does not provide a way to configure the length of the path to use in the output.

You can partially get rid of the path by passing trimpath flags to go build:

go build \
    -gcflags="all=-trimpath=${GOPATH}" \
    -asmflags "all=-trimpath=${GOPATH}" \
    ./...

duplicate of #887

Was this page helpful?
0 / 5 - 0 ratings