Added commonOp.errorLogger.

geesefs-0-30-9
Aaron Jacobs 2015-05-25 14:15:49 +10:00
parent e0db5cf622
commit 41f376af5f
2 changed files with 13 additions and 1 deletions

View File

@ -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)
}

View File

@ -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.