Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/shigola/cmd/cache/seed_purge.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ func seedPurgeCommand(_ *cobra.Command, _ []string) (err error) {
}
}()

log.Info("zoom list: ", zooms)
log.Info("tile matrix set: ", seedPurgeGrid.ID())
log.Info("zoom list:", zooms)
log.Info("tile matrix set:", seedPurgeGrid.ID())
tileChannel := generateTilesForBounds(ctx, seedPurgeBounds, zooms, seedPurgeGrid)

return doWork(ctx, tileChannel, seedPurgeMaps, cacheConcurrency, seedPurgeWorker)
Expand Down
2 changes: 1 addition & 1 deletion cmd/shigola/cmd/cache/tile_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func tileListCommand(cmd *cobra.Command, args []string) (err error) {
defer tileListFile.Close()
}

log.Info("zoom list: ", zooms)
log.Info("zoom list:", zooms)

tilechannel := generateTilesForTileList(ctx, in, explicit, zooms, format)

Expand Down
2 changes: 1 addition & 1 deletion cmd/shigola/cmd/cache/tile_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func tileNameCommand(cmd *cobra.Command, args []string) (err error) {
}
}()

log.Info("zoom list: ", zooms)
log.Info("zoom list:", zooms)
tilechannel := generateTilesForTileName(ctx, tileNameTile, explicit, zooms)

// start up workers
Expand Down
3 changes: 3 additions & 0 deletions internal/log/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ the call sites inherited from tegola, and log through `slog.Default()`:
All of them attach the first non-nil `error` among their arguments under `err`,
so `log.Errorf("tier get: %v", err)` produces both a readable message and a
structured error. A disabled level returns before formatting anything.

`fmt.Println` puts a space between every pair of operands, so a message passed to
`Error`, `Warn`, `Info` or `Debug` should not end in one: `log.Info("zoom list:", zooms)`.
8 changes: 4 additions & 4 deletions internal/log/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ func TestWrappers(t *testing.T) {
wantMsg: "boom",
wantErr: "boom",
},
// Operands are separated as Println separates them — always by a
// space — which reads right for the call sites that pass a message
// and a value, and doubles the space where the message already ends
// in one ("zoom list: ", zooms).
// Operands are separated as Println separates them, always by a
// space. That reads right for a message and a value, and doubles the
// space where the message already ends in one, which is why no call
// site's message does.
"a message and a value": {
emit: func() { log.Info("zoom list:", []int{0, 1}) },
wantMsg: "zoom list: [0 1]",
Expand Down
11 changes: 8 additions & 3 deletions internal/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,14 @@ func Debugf(format string, args ...any) {
}

// Error, Warn, Info and Debug format their operands as fmt.Sprintln does,
// without the newline: the call sites were written against that
// ("zoom list: ", zooms), and against an error on its own, which Println
// renders as its message.
// without the newline. The call sites pass operands — usually a message, a
// message and a value ("zoom list:", zooms), or an error on its own, which
// Println renders as its message. Println always separates operands with a
// space, so a message must not end in one.
//
// fmt.Sprint was the other candidate, and would have spared the call sites
// written as ("zoom list: ", zooms), but it puts no space next to a string
// operand: ("could not purge", err) would have read "could not purgeboom".
//
// They used to pass args[0].(string) to slog as the message and all of args as
// attributes, so a non-string first argument — log.Error(err) — panicked, and
Expand Down
Loading