Skip to content

Commit

Permalink
Allow better time precision in logs (#14)
Browse files Browse the repository at this point in the history
Previously, the logs were sent with only second precision, which quickly
gets suboptimal when dealing with lots of log events happening at more
or less the same time.

This patch allows for milliseconds, as it sends the second value *with
decimals*.
  • Loading branch information
sokkalf authored Jan 5, 2025
1 parent ab35199 commit 2ccf4f5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (h *GraylogHandler) Handle(ctx context.Context, record slog.Record) error {
Host: h.option.hostname,
Short: short(&record),
Full: strings.TrimSpace(record.Message),
TimeUnix: float64(record.Time.Unix()),
TimeUnix: float64(record.Time.UnixNano()) / 1e9,
Level: LogLevels[record.Level],
Facility: h.option.Writer.Facility,
Extra: extra,
Expand Down

0 comments on commit 2ccf4f5

Please sign in to comment.