Added commonOp.errorLogger.
parent
e0db5cf622
commit
41f376af5f
|
@ -16,6 +16,7 @@ package fuseops
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
|
@ -50,6 +51,9 @@ type commonOp struct {
|
|||
// first argument is a call depth.
|
||||
debugLog func(int, string, ...interface{})
|
||||
|
||||
// A logger to be used for logging exceptional errors.
|
||||
errorLogger *log.Logger
|
||||
|
||||
// A function that is invoked with the error given to Respond, for use in
|
||||
// closing off traces and reporting back to the connection.
|
||||
finished func(error)
|
||||
|
@ -77,12 +81,14 @@ func (o *commonOp) init(
|
|||
op internalOp,
|
||||
bazilReq bazilfuse.Request,
|
||||
debugLog func(int, string, ...interface{}),
|
||||
errorLogger *log.Logger,
|
||||
finished func(error)) {
|
||||
// Initialize basic fields.
|
||||
o.ctx = ctx
|
||||
o.op = op
|
||||
o.bazilReq = bazilReq
|
||||
o.debugLog = debugLog
|
||||
o.errorLogger = errorLogger
|
||||
o.finished = finished
|
||||
|
||||
// Set up a trace span for this op.
|
||||
|
@ -130,6 +136,11 @@ func (o *commonOp) Respond(err error) {
|
|||
o.op.ShortDesc(),
|
||||
err)
|
||||
|
||||
o.errorLogger.Printf(
|
||||
"(%s) error: %v",
|
||||
o.op.ShortDesc(),
|
||||
err)
|
||||
|
||||
// Send a response to the kernel.
|
||||
o.bazilReq.RespondError(err)
|
||||
}
|
||||
|
|
|
@ -77,7 +77,8 @@ type MountConfig struct {
|
|||
ReadOnly bool
|
||||
|
||||
// A logger to use for logging errors. All errors are logged, with the
|
||||
// exception of a few blacklisted errors that are expected.
|
||||
// exception of a few blacklisted errors that are expected. If nil, no error
|
||||
// logging is performed.
|
||||
ErrorLogger *log.Logger
|
||||
|
||||
// OS X only.
|
||||
|
|
Loading…
Reference in New Issue