Use nano-second time stamp granularity in the debug log

It's overkill for most purposes, but I'd say it doesn't hurt to have the
extra resolution available in the raw JSON data for the few cases where
it's useful. Have "lazygit -l" print them with milli-second resolution;
that seems to be a good middle ground.
This commit is contained in:
Stefan Haller 2026-08-15 07:35:23 +02:00
parent 1248ac4457
commit d298a7ce4b
2 changed files with 4 additions and 1 deletions

View file

@ -4,6 +4,7 @@ import (
"io"
"log"
"os"
"time"
"github.com/sirupsen/logrus"
)
@ -49,7 +50,7 @@ func NewDevelopmentLogger(logPath string) *logrus.Entry {
func formatted(log *logrus.Logger) *logrus.Entry {
// highly recommended: tail -f development.log | humanlog
// https://github.com/aybabtme/humanlog
log.Formatter = &logrus.JSONFormatter{}
log.Formatter = &logrus.JSONFormatter{TimestampFormat: time.RFC3339Nano}
return log.WithFields(logrus.Fields{})
}

View file

@ -4,6 +4,7 @@ import (
"fmt"
"log"
"os"
"time"
"github.com/aybabtme/humanlog"
)
@ -15,6 +16,7 @@ func TailLogs(logFilePath string) {
opts := humanlog.DefaultOptions
opts.Truncates = false
opts.TimeFormat = time.StampMilli
_, err := os.Stat(logFilePath)
if err != nil {