From 9e014da0b91e696976edec05982573aa4f335547 Mon Sep 17 00:00:00 2001 From: Manu NALEPA Date: Wed, 16 Jul 2025 12:07:12 +0200 Subject: [PATCH] Log: Add milliseconds to log timestamps (#15496) --- changelog/manu-log-ms.md | 3 +++ cmd/beacon-chain/main.go | 7 ++++--- cmd/client-stats/main.go | 6 ++++-- cmd/validator/main.go | 7 ++++--- tools/pcli/main.go | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 changelog/manu-log-ms.md diff --git a/changelog/manu-log-ms.md b/changelog/manu-log-ms.md new file mode 100644 index 0000000000..83cee9a180 --- /dev/null +++ b/changelog/manu-log-ms.md @@ -0,0 +1,3 @@ +### Changed +- Add milliseconds to log timestamps. + diff --git a/cmd/beacon-chain/main.go b/cmd/beacon-chain/main.go index f38e4f3f3f..650b38a7a5 100644 --- a/cmd/beacon-chain/main.go +++ b/cmd/beacon-chain/main.go @@ -7,7 +7,6 @@ import ( "os" "path/filepath" runtimeDebug "runtime/debug" - "time" "github.com/OffchainLabs/prysm/v6/beacon-chain/builder" "github.com/OffchainLabs/prysm/v6/beacon-chain/node" @@ -167,7 +166,7 @@ func before(ctx *cli.Context) error { switch format { case "text": formatter := new(prefixed.TextFormatter) - formatter.TimestampFormat = time.DateTime + formatter.TimestampFormat = "2006-01-02 15:04:05.00" formatter.FullTimestamp = true // If persistent log files are written - we disable the log messages coloring because @@ -183,7 +182,9 @@ func before(ctx *cli.Context) error { logrus.SetFormatter(f) case "json": - logrus.SetFormatter(&logrus.JSONFormatter{}) + logrus.SetFormatter(&logrus.JSONFormatter{ + TimestampFormat: "2006-01-02 15:04:05.00", + }) case "journald": if err := journald.Enable(); err != nil { return err diff --git a/cmd/client-stats/main.go b/cmd/client-stats/main.go index 3a5c4924b4..41d3449d70 100644 --- a/cmd/client-stats/main.go +++ b/cmd/client-stats/main.go @@ -60,7 +60,7 @@ func main() { switch format { case "text": formatter := new(prefixed.TextFormatter) - formatter.TimestampFormat = time.DateTime + formatter.TimestampFormat = "2006-01-02 15:04:05.00" formatter.FullTimestamp = true // If persistent log files are written - we disable the log messages coloring because // the colors are ANSI codes and seen as gibberish in the log files. @@ -73,7 +73,9 @@ func main() { } logrus.SetFormatter(f) case "json": - logrus.SetFormatter(&logrus.JSONFormatter{}) + logrus.SetFormatter(&logrus.JSONFormatter{ + TimestampFormat: "2006-01-02 15:04:05.00", + }) case "journald": if err := journald.Enable(); err != nil { return err diff --git a/cmd/validator/main.go b/cmd/validator/main.go index f109de0dee..b7617eb7b9 100644 --- a/cmd/validator/main.go +++ b/cmd/validator/main.go @@ -8,7 +8,6 @@ import ( "os" "path/filepath" runtimeDebug "runtime/debug" - "time" "github.com/OffchainLabs/prysm/v6/cmd" accountcommands "github.com/OffchainLabs/prysm/v6/cmd/validator/accounts" @@ -152,7 +151,7 @@ func main() { switch format { case "text": formatter := new(prefixed.TextFormatter) - formatter.TimestampFormat = time.DateTime + formatter.TimestampFormat = "2006-01-02 15:04:05.00" formatter.FullTimestamp = true // If persistent log files are written - we disable the log messages coloring because // the colors are ANSI codes and seen as gibberish in the log files. @@ -165,7 +164,9 @@ func main() { } logrus.SetFormatter(f) case "json": - logrus.SetFormatter(&logrus.JSONFormatter{}) + logrus.SetFormatter(&logrus.JSONFormatter{ + TimestampFormat: "2006-01-02 15:04:05.00", + }) case "journald": if err := journald.Enable(); err != nil { return err diff --git a/tools/pcli/main.go b/tools/pcli/main.go index 398660e5c5..460e8a1ff0 100644 --- a/tools/pcli/main.go +++ b/tools/pcli/main.go @@ -303,7 +303,7 @@ var stateTransitionCommand = &cli.Command{ func main() { customFormatter := new(prefixed.TextFormatter) - customFormatter.TimestampFormat = time.DateTime + customFormatter.TimestampFormat = "2006-01-02 15:04:05.00" customFormatter.FullTimestamp = true log.SetFormatter(customFormatter) app := cli.App{}