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

feat: enable Provider verbose logging for statements #851

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

vfoucault
Copy link
Contributor

Currently, Provider with WithVerbose is not honored by the provider.

Simplest approach was to update runGo and runSQL to make these functions Pointer Receiver of Provider in order to have a provider Config reachable.

Another approach would be to overload the Context with ContextWithValue and set cfg, which is dirtier IMHO because it leaves us with an interface casting.

Reusing the global verbose variable and verbose logging is not a good idea either because this is not a per provider behaviour and still the logger won't be reachable.

Currently, `Provider` with `WithVerbose` is not honored by the provider.

Simplest approach was to update `runGo` and `runSQL` to make these functions Pointer Receiver of `Provider` in order to have a provider `Config` reachable.

Another approach would be to overload the `Context` with `ContextWithValue` and set `cfg`, which is dirtier IMHO because it leaves us with an interface casting

Reusing the global `verbose` variable and verbose logging is not a good idea either because this is not a per provider behaviour.
@@ -437,6 +438,9 @@ func runSQL(ctx context.Context, db database.DBTxConn, m *Migration, direction b
statements = m.sql.Down
}
for _, stmt := range statements {
if p.cfg.verbose {
p.cfg.logger.Printf("Excuting statement: %s", stmt)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I want these in my logs when enabling verbose logging. I.e., I care about the final output of the migration, and less about the individual statements. This almost feels more like debugging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tricky then, because this is exactly the same as

verboseInfo("Executing statement: %s\n", clearStatement(query))

Here, I've just added the same behaviour for the provider as the goose usage without provider.

This almost feels more like debugging.

Not really, since this is executed in an ideal world under some CD tooling, by any team, if would be nice to ensure that we have enough logs to assess a situation.
We had an issue where adding 40 columns, only 14 where added. We discovered why, but it would have helped to have the Goose Executing Statement log.

For me, this is verbose logging behaviour that is supposed to be handled the right way by the provider. If, what is WithVerbose used for ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay fair, I think I can get behind this.

@vfoucault
Copy link
Contributor Author

I'd be happy to further discuss this. tia.

@mfridman mfridman changed the title feat: Provider Verbose logging feat: enable Provider verbose logging for statements Nov 20, 2024
@mfridman mfridman merged commit f3d1dc4 into pressly:master Nov 20, 2024
4 checks passed
@vfoucault vfoucault deleted the feat/provider_verbose_logging branch November 20, 2024 14:46
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

Successfully merging this pull request may close these issues.

2 participants