summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-02-28 09:02:18 +0100
committerJakob Unterwurzacher2018-02-28 09:02:18 +0100
commitb96e3ee2717531e842c492c3a6799d1d0c3e51cb (patch)
tree3597324345ac4189c833b968465f07910dcbc534
parentac8f8bf4328d6d5c346004c7c0ef8e651aeaef93 (diff)
tlog: stop embedding log.Logger to prevent mistakes
A few places have called tlog.Warn.Print, which directly calls into log.Logger due to embedding, losing all features of tlog. Stop embedding log.Logger to make sure the internal functions cannot be called accidentially and fix (several!) instances that did.
-rw-r--r--internal/cryptocore/cryptocore.go2
-rw-r--r--internal/fusefrontend/file_allocate_truncate.go2
-rw-r--r--internal/tlog/log.go4
-rw-r--r--mount.go4
4 files changed, 6 insertions, 6 deletions
diff --git a/internal/cryptocore/cryptocore.go b/internal/cryptocore/cryptocore.go
index bd30029..d66f390 100644
--- a/internal/cryptocore/cryptocore.go
+++ b/internal/cryptocore/cryptocore.go
@@ -163,7 +163,7 @@ func (c *CryptoCore) Wipe() {
w := c.AEADCipher.(wiper)
w.Wipe()
} else {
- tlog.Debug.Print("CryptoCore.Wipe: Only nil'ing stdlib refs")
+ tlog.Debug.Printf("CryptoCore.Wipe: Only nil'ing stdlib refs")
}
// We have no access to the keys (or key-equivalents) stored inside the
// Go stdlib. Best we can is to nil the references and force a GC.
diff --git a/internal/fusefrontend/file_allocate_truncate.go b/internal/fusefrontend/file_allocate_truncate.go
index 86aee8e..67254dc 100644
--- a/internal/fusefrontend/file_allocate_truncate.go
+++ b/internal/fusefrontend/file_allocate_truncate.go
@@ -39,7 +39,7 @@ var allocateWarnOnce sync.Once
func (f *file) Allocate(off uint64, sz uint64, mode uint32) fuse.Status {
if mode != FALLOC_DEFAULT && mode != FALLOC_FL_KEEP_SIZE {
f := func() {
- tlog.Warn.Print("fallocate: only mode 0 (default) and 1 (keep size) are supported")
+ tlog.Warn.Printf("fallocate: only mode 0 (default) and 1 (keep size) are supported")
}
allocateWarnOnce.Do(f)
return fuse.Status(syscall.EOPNOTSUPP)
diff --git a/internal/tlog/log.go b/internal/tlog/log.go
index 720bb88..f6c0acf 100644
--- a/internal/tlog/log.go
+++ b/internal/tlog/log.go
@@ -53,7 +53,7 @@ type toggledLogger struct {
prefix string
postfix string
- *log.Logger
+ Logger *log.Logger
}
func (l *toggledLogger) Printf(format string, v ...interface{}) {
@@ -125,7 +125,7 @@ func (l *toggledLogger) SwitchToSyslog(p syslog.Priority) {
if err != nil {
Warn.Printf("SwitchToSyslog: %v", err)
} else {
- l.SetOutput(w)
+ l.Logger.SetOutput(w)
}
}
diff --git a/mount.go b/mount.go
index 9560efe..21a70af 100644
--- a/mount.go
+++ b/mount.go
@@ -89,7 +89,7 @@ func doMount(args *argContainer) {
defer func() {
err = sock.Close()
if err != nil {
- tlog.Warn.Print(err)
+ tlog.Warn.Printf("ctlsock close: %v", err)
}
}()
}
@@ -378,7 +378,7 @@ func handleSigint(srv *fuse.Server, mountpoint string) {
<-ch
err := srv.Unmount()
if err != nil {
- tlog.Warn.Print(err)
+ tlog.Warn.Printf("handleSigint: srv.Unmount returned %v", err)
if runtime.GOOS == "linux" {
// MacOSX does not support lazy unmount
tlog.Info.Printf("Trying lazy unmount")