forked from keybase/kbfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.go
More file actions
32 lines (27 loc) · 879 Bytes
/
debug.go
File metadata and controls
32 lines (27 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2016 Keybase Inc. All rights reserved.
// Use of this source code is governed by a BSD
// license that can be found in the LICENSE file.
package libfuse
import (
"fmt"
"regexp"
"github.com/keybase/client/go/logger"
)
var statfsOrAccessRegexp = regexp.MustCompile(`^(<-|->).* (Statfs|Access)`)
// MakeFuseDebugFn returns a function that logs its argument to the
// given log, suitable to assign to fuse.Debug.
func MakeFuseDebugFn(
log logger.Logger, superVerbose bool) func(msg interface{}) {
return func(msg interface{}) {
str := fmt.Sprintf("%s", msg)
// If superVerbose is not set, filter out Statfs and
// Access messages, since they're spammy on OS X.
//
// Ideally, bazil would let us filter this better, and
// also pass in the ctx.
if !superVerbose && statfsOrAccessRegexp.MatchString(str) {
return
}
log.Debug("%s", str)
}
}