Skip to content

slog.Logger duplicates time & level #29

Description

@zonescape

This example

// Create lgr logger
lgrLogger := lgr.New(lgr.Debug, lgr.Msec)

// Convert to slog handler and create slog logger
handler := lgr.ToSlogHandler(lgrLogger)
logger := slog.New(handler)

// Use standard slog API with lgr formatting
logger.Info("message", "key1", "value1")
// Output: 2023/09/15 10:34:56.789 INFO  message key1="value1"

actually outputs time & level twice:

// Output: 2023/09/15 10:34:56.789 INFO  2023/09/15 10:34:56.789 INFO message key1="value1"

If you log at DEBUG level, than you get INFO & DEBUG levels at once:

logger.Debug("message", "key1", "value1")
// Output: 2023/09/15 10:34:56.789 INFO  2023/09/15 10:34:56.789 DEBUG message key1="value1"

I suggest to remove this lines completely.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions