Skip to content

Commit

Permalink
chore: remove timestamp because it have built-in time
Browse files Browse the repository at this point in the history
  • Loading branch information
erzhae committed Oct 17, 2024
1 parent 573d680 commit 566ad61
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"io"
"log/slog"
"os"
"time"
)

type (
Expand Down Expand Up @@ -44,13 +43,11 @@ func NewLogger(serviceName string, level slog.Level, out io.Writer) Logger {

func (l *logger) log(ctx context.Context, level slog.Level, msg string, args ...any) {
l.slog.LogAttrs(ctx, level, msg,
slog.String("timestamp", time.Now().Format(time.RFC3339)),
slog.Any("data", args))
}

func (l *logger) logWithFields(ctx context.Context, level slog.Level, msg string, fields map[string]interface{}) {
attrs := make([]slog.Attr, 0, len(fields)+1)
attrs = append(attrs, slog.String("timestamp", time.Now().Format(time.RFC3339)))
attrs := make([]slog.Attr, 0)

for k, v := range fields {
attrs = append(attrs, slog.Any(k, v))
Expand Down

0 comments on commit 566ad61

Please sign in to comment.