Skip to content

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

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

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion go/logic/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,14 @@ func (this *Migrator) printStatus(rule PrintStatusRule, writers ...io.Writer) {
)
w := io.MultiWriter(writers...)
fmt.Fprintln(w, status)
this.migrationContext.Log.Infof(status)

// This "hack" is required here because the underlying logging library
// github.com/outbrain/golib/log provides two functions Info and Infof; but the arguments of
// both these functions are eventually redirected to the same function, which internally calls
// fmt.Sprintf. So, the argument of every function called on the DefaultLogger object
// migrationContext.Log will eventually pass through fmt.Sprintf, and thus the '%' character
// needs to be escaped.
this.migrationContext.Log.Info(strings.Replace(status, "%", "%%", 1))

hooksStatusIntervalSec := this.migrationContext.HooksStatusIntervalSec
if hooksStatusIntervalSec > 0 && elapsedSeconds%hooksStatusIntervalSec == 0 {
Expand Down