From 41f376af5f064f36b76f3a55812bd22d334bcc48 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Mon, 25 May 2015 14:15:49 +1000 Subject: [PATCH] Added commonOp.errorLogger. --- fuseops/common_op.go | 11 +++++++++++ mounted_file_system.go | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/fuseops/common_op.go b/fuseops/common_op.go index ccf2d19..2ae773b 100644 --- a/fuseops/common_op.go +++ b/fuseops/common_op.go @@ -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) } diff --git a/mounted_file_system.go b/mounted_file_system.go index e42d443..c3e8211 100644 --- a/mounted_file_system.go +++ b/mounted_file_system.go @@ -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.