Skip to content

Consider replacing logging lib sirupsen/logrus with log/slog #48

@Nicolas-Peiffer

Description

@Nicolas-Peiffer

Consider replacing logging lib https://github.com/sirupsen/logrus with golang standard library log/slog as described in https://go.dev/blog/slog.

Indeed, github.com/sirupsen/logrus latest version is from june 2023, and it is not clear if it is still maintained.
Whereas log/slog is from go standard library (https://cs.opensource.google/go/go/+/master:src/log/slog/;bpv=1). We can expect more maintainance.

However, one drawback is the syntax from log/slog is different from github.com/sirupsen/logrus, because log/slog is structured:

import "github.com/sirupsen/logrus"
// ...
logrus.Infof("Loaded P11 PIN from file: %v", a)
import "log/slog"
// ...
slog.Info("Loaded P11 PIN from file", slog.Any("pin", a))

// or

slog.Info("Loaded P11 PIN from file", "pin", a)

The output should look like this:

2025/01/01 16:27:19 INFO Loaded P11 PIN from file pin=a.value

or depending on the log/slog output handler format of log/slog (text, JSON):

time=2025-01-01T16:56:03.786-04:00 level=INFO msg="hello, world" user=jba

Maybe this could be done at the same time than enhancing the CLI with a --log-level flag, like suggested in #47

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