Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use logrus with v5? #2140

Open
swanden opened this issue Oct 4, 2024 · 1 comment
Open

How to use logrus with v5? #2140

swanden opened this issue Oct 4, 2024 · 1 comment

Comments

@swanden
Copy link

swanden commented Oct 4, 2024

In the version 4 there was a config variable config.ConnConfig.Logger, but in the 5 version there is no such varibale. Please provide the code of how to use github.com/sirupsen/logrus with jackc/pgx.

config, err := pgxpool.ParseConfig(connStr)
if err != nil {
    fmt.Fprintf(os.Stderr, "Unable to parse config: %v\n", err)
    os.Exit(1)
}
looger := &log.Logger{
    Out:          os.Stderr,
    Formatter:    new(log.JSONFormatter),
    Hooks:        make(log.LevelHooks),
    Level:        log.InfoLevel,
    ExitFunc:     os.Exit,
    ReportCaller: false,
}
config.ConnConfig.Logger = logrusadapter.NewLogger(looger)
@jackc
Copy link
Owner

jackc commented Oct 5, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants