Skip to content

Conversation

@marbens-arch
Copy link
Member

Purpose

Improves consistency and makes it a bit easier to change the log level to something else.

Testing

CPU benchmark looks like it works and has the same format as before.

2025-11-23 12:56:18 INF Measured hashing performance (perf="1017.53 MB/s" log.pkg=syncthing)

Improves consistency and makes it a bit easier to change the log level to something else.

Signed-off-by: Marcus B Spencer <[email protected]>
@github-actions github-actions bot added the chore label Nov 23, 2025
@calmh
Copy link
Member

calmh commented Nov 24, 2025

Yes possibly. This had me thinking a bit because it moves the computation to the logging framework, effectively, and I realized there is a bug because we format twice in different ways (internal + stdout), so

index 27844d546..e3f19a59e 100644
--- i/cmd/syncthing/main.go
+++ w/cmd/syncthing/main.go
@@ -51,6 +51,7 @@ import (
        "github.com/syncthing/syncthing/lib/locations"
        "github.com/syncthing/syncthing/lib/osutil"
        "github.com/syncthing/syncthing/lib/protocol"
+       "github.com/syncthing/syncthing/lib/rand"
        "github.com/syncthing/syncthing/lib/svcutil"
        "github.com/syncthing/syncthing/lib/syncthing"
        "github.com/syncthing/syncthing/lib/upgrade"
@@ -429,6 +430,12 @@ func (c *serveCmd) syncthingMain() {
                startPerfStats()
        }
 
+       slog.Info("Expensive stuff", "exp", slogutil.Expensive(func() any {
+               v := rand.String(8)
+               fmt.Println("computed:", v)
+               return v
+       }))
+
        // Print our version information up front, so any crash that happens
        // early etc. will have it available.
        slog.Info(build.LongVersion) //nolint:sloglint
% ../bin/syncthing --home h1                  
computed: H37xEnEX
computed: 74cKe2oH
2025-11-24 15:54:35 INF Expensive stuff (exp=74cKe2oH log.pkg=main)
2025-11-24 15:54:35 INF syncthing v2.0.12-dev.7.gf2e8d0f9.dirty-infrastructure "Hafnium Hornet" (go1.25.4 darwin-arm64) jb@jbo-m3wl72rv 2025-11-17 06:39:17 UTC [stnoupgrade] (log.pkg=main)

that should be fixed probably first...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants