MCPcopy
hub / github.com/restic/restic / Log

Function Log

internal/debug/debug.go:164–207  ·  view source on GitHub ↗

Log prints a message to the debug log (if debug is enabled).

(f string, args ...interface{})

Source from the content-addressed store, hash-verified

162
163// Log prints a message to the debug log (if debug is enabled).
164func Log(f string, args ...interface{}) {
165 if !opts.isEnabled {
166 return
167 }
168
169 fn, dir, file, line := getPosition()
170 goroutine := goroutineNum()
171
172 if len(f) == 0 || f[len(f)-1] != '\n' {
173 f += "\n"
174 }
175
176 type Shortener interface {
177 Str() string
178 }
179
180 for i, item := range args {
181 if shortener, ok := item.(Shortener); ok {
182 args[i] = shortener.Str()
183 }
184 }
185
186 pos := fmt.Sprintf("%s/%s:%d", dir, file, line)
187
188 formatString := fmt.Sprintf("%s\t%s\t%d\t%s", pos, fn, goroutine, f)
189
190 dbgprint := func() {
191 fmt.Fprintf(os.Stderr, formatString, args...)
192 }
193
194 if opts.logger != nil {
195 opts.logger.Printf(formatString, args...)
196 }
197
198 filename := fmt.Sprintf("%s/%s:%d", dir, file, line)
199 if checkFilter(opts.files, filename) {
200 dbgprint()
201 return
202 }
203
204 if checkFilter(opts.funcs, fn) {
205 dbgprint()
206 }
207}

Callers 15

ReadAtFunction · 0.92
writeCachedirTagFunction · 0.92
NewFunction · 0.92
OlderThanFunction · 0.92
loadMethod · 0.92
saveMethod · 0.92
ClearMethod · 0.92
RemoveMethod · 0.92
SaveMethod · 0.92
cacheFileMethod · 0.92
LoadMethod · 0.92
StatMethod · 0.92

Calls 4

getPositionFunction · 0.85
goroutineNumFunction · 0.85
checkFilterFunction · 0.85
StrMethod · 0.65

Tested by 5

BenchmarkLogStaticFunction · 0.74
BenchmarkLogIDStrFunction · 0.74
BenchmarkLogIDStringFunction · 0.74
TestEnsureTreeFunction · 0.74