From 2919b769475dd2d0dde050d4b54bb42575523345 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sat, 16 Jan 2016 23:01:57 +0100 Subject: [PATCH] The "OK" log level is silly and should not exist --- cmd/syncthing/main.go | 8 ++++---- lib/logger/logger.go | 21 --------------------- lib/logger/logger_test.go | 11 ++--------- lib/model/model.go | 4 ++-- 4 files changed, 8 insertions(+), 36 deletions(-) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 8d72eacbc..6bc141619 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -338,7 +338,7 @@ func main() { if err != nil { l.Fatalln("Upgrade:", err) // exits 1 } - l.Okln("Upgraded from", options.upgradeTo) + l.Infoln("Upgraded from", options.upgradeTo) return } @@ -462,14 +462,14 @@ func performUpgrade(release upgrade.Release) { if err != nil { l.Fatalln("Upgrade:", err) } - l.Okf("Upgraded to %q", release.Tag) + l.Infof("Upgraded to %q", release.Tag) } else { l.Infoln("Attempting upgrade through running Syncthing...") err = upgradeViaRest() if err != nil { l.Fatalln("Upgrade:", err) } - l.Okln("Syncthing upgrading") + l.Infoln("Syncthing upgrading") os.Exit(exitUpgrading) } } @@ -850,7 +850,7 @@ func syncthingMain(runtimeOptions RuntimeOptions) { mainService.Stop() - l.Okln("Exiting") + l.Infoln("Exiting") if runtimeOptions.cpuProfile { pprof.StopCPUProfile() diff --git a/lib/logger/logger.go b/lib/logger/logger.go index 5b59a598b..54736cc12 100644 --- a/lib/logger/logger.go +++ b/lib/logger/logger.go @@ -23,7 +23,6 @@ const ( LevelDebug LogLevel = iota LevelVerbose LevelInfo - LevelOK LevelWarn LevelFatal NumLevels @@ -42,8 +41,6 @@ type Logger interface { Verbosef(format string, vals ...interface{}) Infoln(vals ...interface{}) Infof(format string, vals ...interface{}) - Okln(vals ...interface{}) - Okf(format string, vals ...interface{}) Warnln(vals ...interface{}) Warnf(format string, vals ...interface{}) Fatalln(vals ...interface{}) @@ -165,24 +162,6 @@ func (l *logger) Infof(format string, vals ...interface{}) { l.callHandlers(LevelInfo, s) } -// Okln logs a line with an OK prefix. -func (l *logger) Okln(vals ...interface{}) { - l.mut.Lock() - defer l.mut.Unlock() - s := fmt.Sprintln(vals...) - l.logger.Output(2, "OK: "+s) - l.callHandlers(LevelOK, s) -} - -// Okf logs a formatted line with an OK prefix. -func (l *logger) Okf(format string, vals ...interface{}) { - l.mut.Lock() - defer l.mut.Unlock() - s := fmt.Sprintf(format, vals...) - l.logger.Output(2, "OK: "+s) - l.callHandlers(LevelOK, s) -} - // Warnln logs a formatted line with a WARNING prefix. func (l *logger) Warnln(vals ...interface{}) { l.mut.Lock() diff --git a/lib/logger/logger_test.go b/lib/logger/logger_test.go index 9f1e1f8c0..d807213be 100644 --- a/lib/logger/logger_test.go +++ b/lib/logger/logger_test.go @@ -19,8 +19,6 @@ func TestAPI(t *testing.T) { l.AddHandler(LevelDebug, checkFunc(t, LevelDebug, &debug)) info := 0 l.AddHandler(LevelInfo, checkFunc(t, LevelInfo, &info)) - ok := 0 - l.AddHandler(LevelOK, checkFunc(t, LevelOK, &ok)) warn := 0 l.AddHandler(LevelWarn, checkFunc(t, LevelWarn, &warn)) @@ -28,20 +26,15 @@ func TestAPI(t *testing.T) { l.Debugln("test", 0) l.Infof("test %d", 1) l.Infoln("test", 1) - l.Okf("test %d", 2) - l.Okln("test", 2) l.Warnf("test %d", 3) l.Warnln("test", 3) - if debug != 8 { + if debug != 6 { t.Errorf("Debug handler called %d != 8 times", debug) } - if info != 6 { + if info != 4 { t.Errorf("Info handler called %d != 6 times", info) } - if ok != 4 { - t.Errorf("Ok handler called %d != 4 times", ok) - } if warn != 2 { t.Errorf("Warn handler called %d != 2 times", warn) } diff --git a/lib/model/model.go b/lib/model/model.go index 90bbd68dd..6d9d0b3b8 100644 --- a/lib/model/model.go +++ b/lib/model/model.go @@ -189,7 +189,7 @@ func (m *Model) StartFolderRW(folder string) { m.folderRunnerTokens[folder] = append(m.folderRunnerTokens[folder], token) m.fmut.Unlock() - l.Okln("Ready to synchronize", folder, "(read-write)") + l.Infoln("Ready to synchronize", folder, "(read-write)") } func (m *Model) warnAboutOverwritingProtectedFiles(folder string) { @@ -241,7 +241,7 @@ func (m *Model) StartFolderRO(folder string) { m.folderRunnerTokens[folder] = append(m.folderRunnerTokens[folder], token) m.fmut.Unlock() - l.Okln("Ready to synchronize", folder, "(read only; no external updates accepted)") + l.Infoln("Ready to synchronize", folder, "(read only; no external updates accepted)") } func (m *Model) RemoveFolder(folder string) {