mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 10:58:55 +00:00
debug: Auto-shorten IDs passed as parameters
This commit is contained in:
parent
d6212ee2d9
commit
ed99f53786
@ -180,6 +180,16 @@ func Log(f string, args ...interface{}) {
|
|||||||
f += "\n"
|
f += "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Shortener interface {
|
||||||
|
Str() string
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, item := range args {
|
||||||
|
if shortener, ok := item.(Shortener); ok {
|
||||||
|
args[i] = shortener.Str()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pos := fmt.Sprintf("%s/%s:%d", dir, file, line)
|
pos := fmt.Sprintf("%s/%s:%d", dir, file, line)
|
||||||
|
|
||||||
formatString := fmt.Sprintf("%s\t%s\t%d\t%s", pos, fn, goroutine, f)
|
formatString := fmt.Sprintf("%s\t%s\t%d\t%s", pos, fn, goroutine, f)
|
||||||
@ -192,7 +202,8 @@ func Log(f string, args ...interface{}) {
|
|||||||
opts.logger.Printf(formatString, args...)
|
opts.logger.Printf(formatString, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if checkFilter(opts.files, fmt.Sprintf("%s/%s:%d", dir, file, line)) {
|
filename := fmt.Sprintf("%s/%s:%d", dir, file, line)
|
||||||
|
if checkFilter(opts.files, filename) {
|
||||||
dbgprint()
|
dbgprint()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ func BenchmarkLogIDStr(b *testing.B) {
|
|||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
debug.Log("id: %v", id.Str())
|
debug.Log("id: %v", id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,6 +29,6 @@ func BenchmarkLogIDString(b *testing.B) {
|
|||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
debug.Log("id: %v", id.String())
|
debug.Log("id: %s", id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user