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.
This commit is contained in:
Jakob Unterwurzacher 2018-02-28 09:02:18 +01:00
parent ac8f8bf432
commit b96e3ee271
4 changed files with 6 additions and 6 deletions

View File

@ -163,7 +163,7 @@ func (c *CryptoCore) Wipe() {
w := c.AEADCipher.(wiper) w := c.AEADCipher.(wiper)
w.Wipe() w.Wipe()
} else { } 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 // 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. // Go stdlib. Best we can is to nil the references and force a GC.

View File

@ -39,7 +39,7 @@ var allocateWarnOnce sync.Once
func (f *file) Allocate(off uint64, sz uint64, mode uint32) fuse.Status { func (f *file) Allocate(off uint64, sz uint64, mode uint32) fuse.Status {
if mode != FALLOC_DEFAULT && mode != FALLOC_FL_KEEP_SIZE { if mode != FALLOC_DEFAULT && mode != FALLOC_FL_KEEP_SIZE {
f := func() { 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) allocateWarnOnce.Do(f)
return fuse.Status(syscall.EOPNOTSUPP) return fuse.Status(syscall.EOPNOTSUPP)

View File

@ -53,7 +53,7 @@ type toggledLogger struct {
prefix string prefix string
postfix string postfix string
*log.Logger Logger *log.Logger
} }
func (l *toggledLogger) Printf(format string, v ...interface{}) { func (l *toggledLogger) Printf(format string, v ...interface{}) {
@ -125,7 +125,7 @@ func (l *toggledLogger) SwitchToSyslog(p syslog.Priority) {
if err != nil { if err != nil {
Warn.Printf("SwitchToSyslog: %v", err) Warn.Printf("SwitchToSyslog: %v", err)
} else { } else {
l.SetOutput(w) l.Logger.SetOutput(w)
} }
} }

View File

@ -89,7 +89,7 @@ func doMount(args *argContainer) {
defer func() { defer func() {
err = sock.Close() err = sock.Close()
if err != nil { 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 <-ch
err := srv.Unmount() err := srv.Unmount()
if err != nil { if err != nil {
tlog.Warn.Print(err) tlog.Warn.Printf("handleSigint: srv.Unmount returned %v", err)
if runtime.GOOS == "linux" { if runtime.GOOS == "linux" {
// MacOSX does not support lazy unmount // MacOSX does not support lazy unmount
tlog.Info.Printf("Trying lazy unmount") tlog.Info.Printf("Trying lazy unmount")