Skip to content

Configure Logger when using embedded migrations #975

@leonnicolas

Description

@leonnicolas

I like to use embedded migrations for testing. However, for each call to Up, this code is run:

log.Printf("goose: successfully migrated database to version: %d", current)

With more tests this becomes very inconvenient.

I could solve it by setting the output of the global default logger to io.Discard.

log.Default().SetOutput(io.Discard)

but in general I would prefer to only discard the logger that is used by goose.

If we would allow to pass a logger as an Option we could not only suppress all logs (useful for tests), but also allow users to pass a logger that complies with their log level and log format.
There are only 52 occurrences of the log package in the goose code base.
If you think this could be useful for more people than just me, I am happy to put some work into this.

Maybe we could also use this opportunity so switch to log/slog?

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