Killed off the --fuse.debug flag.

geesefs-0-30-9
Aaron Jacobs 2015-07-16 10:52:18 +10:00
commit 5eb7759880
6 changed files with 23 additions and 55 deletions

View File

@ -1,51 +0,0 @@
// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package fuse
import (
"flag"
"io"
"io/ioutil"
"log"
"os"
"sync"
)
var fEnableDebug = flag.Bool(
"fuse.debug",
false,
"Write FUSE debugging messages to stderr.")
var gDebugLogger *log.Logger
var gDebugLoggerOnce sync.Once
func initDebugDebugLogger() {
if !flag.Parsed() {
panic("initDebugDebugLogger called before flags available.")
}
var writer io.Writer = ioutil.Discard
if *fEnableDebug {
writer = os.Stderr
}
const flags = log.Ldate | log.Ltime | log.Lmicroseconds
gDebugLogger = log.New(writer, "", flags)
}
func getDebugLogger() *log.Logger {
gDebugLoggerOnce.Do(initDebugDebugLogger)
return gDebugLogger
}

View File

@ -49,7 +49,7 @@ type Op interface {
// Log information tied to this operation, with semantics equivalent to
// log.Printf, except that the format is different and logging is suppressed
// if --fuse.debug is not set.
// if no debug logger was set when mounting.
Logf(format string, v ...interface{})
}

View File

@ -84,6 +84,10 @@ type MountConfig struct {
// logging is performed.
ErrorLogger *log.Logger
// A logger to use for logging debug information. If nil, no debug logging is
// performed.
DebugLogger *log.Logger
// OS X only.
//
// Normally on OS X we mount with the novncache option
@ -189,7 +193,11 @@ func Mount(
dir string,
server Server,
config *MountConfig) (mfs *MountedFileSystem, err error) {
debugLogger := getDebugLogger()
// Arrange for a non-nil debug logger.
debugLogger := config.DebugLogger
if debugLogger == nil {
debugLogger = log.New(ioutil.Discard, "", 0)
}
// Initialize the struct.
mfs = &MountedFileSystem{

View File

@ -18,6 +18,7 @@ import (
"fmt"
"io"
"io/ioutil"
"log"
"os"
"time"
@ -59,7 +60,12 @@ type SampleTest struct {
//
// REQUIRES: t.Server has been set.
func (t *SampleTest) SetUp(ti *ogletest.TestInfo) {
err := t.initialize(ti.Ctx, t.Server, &t.MountConfig)
cfg := t.MountConfig
if *fDebug {
cfg.DebugLogger = log.New(os.Stderr, "fuse: ", 0)
}
err := t.initialize(ti.Ctx, t.Server, &cfg)
if err != nil {
panic(err)
}

View File

@ -40,6 +40,7 @@ var fFlushError = flag.Int("flushfs.flush_error", 0, "")
var fFsyncError = flag.Int("flushfs.fsync_error", 0, "")
var fReadOnly = flag.Bool("read_only", false, "Mount in read-only mode.")
var fDebug = flag.Bool("debug", false, "Enable debug logging.")
func makeFlushFS() (server fuse.Server, err error) {
// Check the flags.
@ -140,6 +141,10 @@ func main() {
ReadOnly: *fReadOnly,
}
if *fDebug {
cfg.DebugLogger = log.New(os.Stderr, "fuse: ", 0)
}
mfs, err := fuse.Mount(*fMountPoint, server, cfg)
if err != nil {
log.Fatalf("Mount: %v", err)

View File

@ -276,7 +276,7 @@ func (t *SubprocessTest) initialize(ctx context.Context) (err error) {
// Handle debug mode.
if *fDebug {
mountCmd.Stderr = os.Stderr
mountCmd.Args = append(mountCmd.Args, "--fuse.debug")
mountCmd.Args = append(mountCmd.Args, "--debug")
}
// Start the command.