From 4e22a966027f0aed5183df1f5dca3b7536ffa3ca Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sat, 27 Jul 2019 11:58:39 +0200 Subject: [PATCH] cmd/syncthing: Print version information early (fixes #5891) (#5893) --- cmd/syncthing/main.go | 8 ++++++++ lib/syncthing/syncthing.go | 7 +------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index e15af61d4..70c7711fa 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -548,6 +548,14 @@ func upgradeViaRest() error { } func syncthingMain(runtimeOptions RuntimeOptions) { + // Set a log prefix similar to the ID we will have later on, or early log + // lines look ugly. + l.SetPrefix("[start] ") + + // Print our version information up front, so any crash that happens + // early etc. will have it available. + l.Infoln(build.LongVersion) + // Ensure that we have a certificate and key. cert, err := syncthing.LoadOrGenerateCertificate( locations.Get(locations.CertFile), diff --git a/lib/syncthing/syncthing.go b/lib/syncthing/syncthing.go index 7b436e6ce..48cb5da87 100644 --- a/lib/syncthing/syncthing.go +++ b/lib/syncthing/syncthing.go @@ -121,10 +121,6 @@ func (a *App) startup() error { }) a.mainService.ServeBackground() - // Set a log prefix similar to the ID we will have later on, or early log - // lines look ugly. - l.SetPrefix("[start] ") - if a.opts.AuditWriter != nil { a.mainService.Add(newAuditService(a.opts.AuditWriter)) } @@ -147,10 +143,9 @@ func (a *App) startup() error { // report the error if there is one. osutil.MaximizeOpenFileLimit() + // Figure out our device ID, set it as the log prefix and log it. a.myID = protocol.NewDeviceID(a.cert.Certificate[0]) l.SetPrefix(fmt.Sprintf("[%s] ", a.myID.String()[:5])) - - l.Infoln(build.LongVersion) l.Infoln("My ID:", a.myID) // Select SHA256 implementation and report. Affected by the