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

Print status to migration context logging after escaping % character #1374

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

icyflame
Copy link
Contributor

Description

The string status has the character % after the progress percentage number. When printed once again using the Infof function, this % is read as a directive for formatting and ends up showing MISSING in the output as shown below:

2024-01-31 12:49:54 INFO Copy: 0/0 100.0%!;(MISSING) Applied: 0; Backlog: 0/1000; Time: 0s(total), 0s(copy); streamer: mysql_bin.000002:79674; Lag: 0.00s, HeartbeatLag: 0.02s, State: migrating; ETA: due

Simply changing Infof to Info does not work here because this.migrationContext.Log is an object of the type DefaultLogger in this repository, which uses the library https://github.com/outbrain/golib/log. That library uses formatting even when the Infofunction is called:
https://github.com/outbrain/golib/blob/2531e5dbcc71b6f8a4ccf1205c209ae89b7529fc/log/log.go#L191-L193

If this patch is not acceptible, then I can also just remove this line. The migration context logger prints the messages which are already printed to STDOUT once again to STDERR with the current time as a prefix. This change was introduced in the commit

this.migrationContext.Log.Infof(status)
, introduced in the PR #1194.

A Pull Request should be associated with an Issue.

We wish to have discussions in Issues. A single issue may be targeted by multiple PRs.
If you're offering a new feature or fixing anything, we'd like to know beforehand in Issues,
and potentially we'll be able to point development in a particular direction.

Related issue: #1373

Further notes in https://github.com/github/gh-ost/blob/master/.github/CONTRIBUTING.md
Thank you! We are open to PRs, but please understand if for technical reasons we are unable to accept each and any PR

In case this PR introduced Go code changes:

  • contributed code is using same conventions as original code
  • script/cibuild returns with no formatting errors, build errors or unit test errors.

The string `status` has the character `%` after the progress percentage number. When printed once
again using the `Infof` function, this `%` is read as a directive for formatting and ends up showing
`MISSING` in the output as shown below:

	2024-01-31 12:49:54 INFO Copy: 0/0 100.0%!;(MISSING) Applied: 0; Backlog: 0/1000; Time: 0s(total), 0s(copy); streamer: mysql_bin.000002:79674; Lag: 0.00s, HeartbeatLag: 0.02s, State: migrating; ETA: due

Simply changing `Infof` to `Info` does not work here because `this.migrationContext.Log` is an
object of the type `DefaultLogger` in this repository, which uses the library
https://github.com/outbrain/golib/log. That library uses formatting __even__ when the `Info`function
is called:
https://github.com/outbrain/golib/blob/2531e5dbcc71b6f8a4ccf1205c209ae89b7529fc/log/log.go#L191-L193

If this patch is not acceptible, then I can also just remove this line. The migration context logger
prints the messages which are already printed to STDOUT once again to STDERR with the current time
as a prefix. This change was introduced in the commit
https://github.com/github/gh-ost/blob/515aa72d3d9b756e454b0168b4e57bc599b45e36/go/logic/migrator.go#L1039,
introduced in the PR github#1194.
@icyflame icyflame marked this pull request as ready for review January 31, 2024 13:31
@meiji163
Copy link
Contributor

Thanks for chasing down the formatting bug~!

@meiji163 meiji163 merged commit a6cddf9 into github:master Jan 31, 2024
7 checks passed
@timvaillancourt
Copy link
Collaborator

Awesome thanks! This reminds me we should move to a modern logger at some point

@icyflame icyflame deleted the print-info-without-formatting branch February 1, 2024 00:39
@timvaillancourt timvaillancourt added this to the v1.1.7 milestone Apr 8, 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

Successfully merging this pull request may close these issues.

3 participants