Log relative path for caller when using `ConsoleWriter` (#267)
* use relative file path
This commit is contained in:
parent
29d8dac5e8
commit
b7e31f4fe7
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -367,10 +368,10 @@ func consoleDefaultFormatCaller(noColor bool) Formatter {
|
||||||
c = cc
|
c = cc
|
||||||
}
|
}
|
||||||
if len(c) > 0 {
|
if len(c) > 0 {
|
||||||
cwd, err := os.Getwd()
|
if cwd, err := os.Getwd(); err == nil {
|
||||||
if err == nil {
|
if rel, err := filepath.Rel(cwd, c); err == nil {
|
||||||
prefix := cwd + "/"
|
c = rel
|
||||||
c = strings.TrimPrefix(c, prefix)
|
}
|
||||||
}
|
}
|
||||||
c = colorize(c, colorBold, noColor) + colorize(" >", colorCyan, noColor)
|
c = colorize(c, colorBold, noColor) + colorize(" >", colorCyan, noColor)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue