From 9d43539da7a3c16b634ba7fb276e8cc2cf0d21a1 Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Thu, 31 Oct 2024 20:21:47 -0400 Subject: [PATCH] feat(cmd/joj3): shorter runID --- cmd/joj3/log.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/joj3/log.go b/cmd/joj3/log.go index aaad675..2383fe4 100644 --- a/cmd/joj3/log.go +++ b/cmd/joj3/log.go @@ -5,6 +5,7 @@ import ( "fmt" "log/slog" "os" + "strconv" "time" ) @@ -17,7 +18,9 @@ type multiHandler struct { var runID string func init() { - runID = fmt.Sprintf("%d-%d", time.Now().UnixNano(), os.Getpid()) + runID = fmt.Sprintf("%06s%04s", + strconv.FormatInt(time.Now().Unix(), 36), + strconv.FormatInt(int64(os.Getpid()), 36)) } func (h *multiHandler) Enabled(ctx context.Context, level slog.Level) bool {