@@ -31,7 +31,7 @@ func acceptSignals(migrationContext *base.MigrationContext) {
31
31
for sig := range c {
32
32
switch sig {
33
33
case syscall .SIGHUP :
34
- log .Infof ("Received SIGHUP. Reloading configuration" )
34
+ migrationContext . Log .Infof ("Received SIGHUP. Reloading configuration" )
35
35
if err := migrationContext .ReadConfigFile (); err != nil {
36
36
log .Errore (err )
37
37
} else {
@@ -156,69 +156,69 @@ func main() {
156
156
return
157
157
}
158
158
159
- log .SetLevel (log .ERROR )
159
+ migrationContext . Log .SetLevel (log .ERROR )
160
160
if * verbose {
161
- log .SetLevel (log .INFO )
161
+ migrationContext . Log .SetLevel (log .INFO )
162
162
}
163
163
if * debug {
164
- log .SetLevel (log .DEBUG )
164
+ migrationContext . Log .SetLevel (log .DEBUG )
165
165
}
166
166
if * stack {
167
- log .SetPrintStackTrace (* stack )
167
+ migrationContext . Log .SetPrintStackTrace (* stack )
168
168
}
169
169
if * quiet {
170
170
// Override!!
171
- log .SetLevel (log .ERROR )
171
+ migrationContext . Log .SetLevel (log .ERROR )
172
172
}
173
173
174
174
if migrationContext .DatabaseName == "" {
175
- log .Fatalf ("--database must be provided and database name must not be empty" )
175
+ migrationContext . Log .Fatalf ("--database must be provided and database name must not be empty" )
176
176
}
177
177
if migrationContext .OriginalTableName == "" {
178
- log .Fatalf ("--table must be provided and table name must not be empty" )
178
+ migrationContext . Log .Fatalf ("--table must be provided and table name must not be empty" )
179
179
}
180
180
if migrationContext .AlterStatement == "" {
181
- log .Fatalf ("--alter must be provided and statement must not be empty" )
181
+ migrationContext . Log .Fatalf ("--alter must be provided and statement must not be empty" )
182
182
}
183
183
migrationContext .Noop = ! (* executeFlag )
184
184
if migrationContext .AllowedRunningOnMaster && migrationContext .TestOnReplica {
185
- log .Fatalf ("--allow-on-master and --test-on-replica are mutually exclusive" )
185
+ migrationContext . Log .Fatalf ("--allow-on-master and --test-on-replica are mutually exclusive" )
186
186
}
187
187
if migrationContext .AllowedRunningOnMaster && migrationContext .MigrateOnReplica {
188
- log .Fatalf ("--allow-on-master and --migrate-on-replica are mutually exclusive" )
188
+ migrationContext . Log .Fatalf ("--allow-on-master and --migrate-on-replica are mutually exclusive" )
189
189
}
190
190
if migrationContext .MigrateOnReplica && migrationContext .TestOnReplica {
191
- log .Fatalf ("--migrate-on-replica and --test-on-replica are mutually exclusive" )
191
+ migrationContext . Log .Fatalf ("--migrate-on-replica and --test-on-replica are mutually exclusive" )
192
192
}
193
193
if migrationContext .SwitchToRowBinlogFormat && migrationContext .AssumeRBR {
194
- log .Fatalf ("--switch-to-rbr and --assume-rbr are mutually exclusive" )
194
+ migrationContext . Log .Fatalf ("--switch-to-rbr and --assume-rbr are mutually exclusive" )
195
195
}
196
196
if migrationContext .TestOnReplicaSkipReplicaStop {
197
197
if ! migrationContext .TestOnReplica {
198
- log .Fatalf ("--test-on-replica-skip-replica-stop requires --test-on-replica to be enabled" )
198
+ migrationContext . Log .Fatalf ("--test-on-replica-skip-replica-stop requires --test-on-replica to be enabled" )
199
199
}
200
- log .Warning ("--test-on-replica-skip-replica-stop enabled. We will not stop replication before cut-over. Ensure you have a plugin that does this." )
200
+ migrationContext . Log .Warning ("--test-on-replica-skip-replica-stop enabled. We will not stop replication before cut-over. Ensure you have a plugin that does this." )
201
201
}
202
202
if migrationContext .CliMasterUser != "" && migrationContext .AssumeMasterHostname == "" {
203
- log .Fatalf ("--master-user requires --assume-master-host" )
203
+ migrationContext . Log .Fatalf ("--master-user requires --assume-master-host" )
204
204
}
205
205
if migrationContext .CliMasterPassword != "" && migrationContext .AssumeMasterHostname == "" {
206
- log .Fatalf ("--master-password requires --assume-master-host" )
206
+ migrationContext . Log .Fatalf ("--master-password requires --assume-master-host" )
207
207
}
208
208
if migrationContext .TLSCACertificate != "" && ! migrationContext .UseTLS {
209
- log .Fatalf ("--ssl-ca requires --ssl" )
209
+ migrationContext . Log .Fatalf ("--ssl-ca requires --ssl" )
210
210
}
211
211
if migrationContext .TLSCertificate != "" && ! migrationContext .UseTLS {
212
- log .Fatalf ("--ssl-cert requires --ssl" )
212
+ migrationContext . Log .Fatalf ("--ssl-cert requires --ssl" )
213
213
}
214
214
if migrationContext .TLSKey != "" && ! migrationContext .UseTLS {
215
- log .Fatalf ("--ssl-key requires --ssl" )
215
+ migrationContext . Log .Fatalf ("--ssl-key requires --ssl" )
216
216
}
217
217
if migrationContext .TLSAllowInsecure && ! migrationContext .UseTLS {
218
- log .Fatalf ("--ssl-allow-insecure requires --ssl" )
218
+ migrationContext . Log .Fatalf ("--ssl-allow-insecure requires --ssl" )
219
219
}
220
220
if * replicationLagQuery != "" {
221
- log .Warningf ("--replication-lag-query is deprecated" )
221
+ migrationContext . Log .Warningf ("--replication-lag-query is deprecated" )
222
222
}
223
223
224
224
switch * cutOver {
@@ -227,19 +227,19 @@ func main() {
227
227
case "two-step" :
228
228
migrationContext .CutOverType = base .CutOverTwoStep
229
229
default :
230
- log .Fatalf ("Unknown cut-over: %s" , * cutOver )
230
+ migrationContext . Log .Fatalf ("Unknown cut-over: %s" , * cutOver )
231
231
}
232
232
if err := migrationContext .ReadConfigFile (); err != nil {
233
- log .Fatale (err )
233
+ migrationContext . Log .Fatale (err )
234
234
}
235
235
if err := migrationContext .ReadThrottleControlReplicaKeys (* throttleControlReplicas ); err != nil {
236
- log .Fatale (err )
236
+ migrationContext . Log .Fatale (err )
237
237
}
238
238
if err := migrationContext .ReadMaxLoad (* maxLoad ); err != nil {
239
- log .Fatale (err )
239
+ migrationContext . Log .Fatale (err )
240
240
}
241
241
if err := migrationContext .ReadCriticalLoad (* criticalLoad ); err != nil {
242
- log .Fatale (err )
242
+ migrationContext . Log .Fatale (err )
243
243
}
244
244
if migrationContext .ServeSocketFile == "" {
245
245
migrationContext .ServeSocketFile = fmt .Sprintf ("/tmp/gh-ost.%s.%s.sock" , migrationContext .DatabaseName , migrationContext .OriginalTableName )
@@ -248,7 +248,7 @@ func main() {
248
248
fmt .Println ("Password:" )
249
249
bytePassword , err := terminal .ReadPassword (int (syscall .Stdin ))
250
250
if err != nil {
251
- log .Fatale (err )
251
+ migrationContext . Log .Fatale (err )
252
252
}
253
253
migrationContext .CliPassword = string (bytePassword )
254
254
}
@@ -262,13 +262,13 @@ func main() {
262
262
migrationContext .SetDefaultNumRetries (* defaultRetries )
263
263
migrationContext .ApplyCredentials ()
264
264
if err := migrationContext .SetupTLS (); err != nil {
265
- log .Fatale (err )
265
+ migrationContext . Log .Fatale (err )
266
266
}
267
267
if err := migrationContext .SetCutOverLockTimeoutSeconds (* cutOverLockTimeoutSeconds ); err != nil {
268
- log .Errore (err )
268
+ migrationContext . Log .Errore (err )
269
269
}
270
270
if err := migrationContext .SetExponentialBackoffMaxInterval (* exponentialBackoffMaxInterval ); err != nil {
271
- log .Errore (err )
271
+ migrationContext . Log .Errore (err )
272
272
}
273
273
274
274
log .Infof ("starting gh-ost %+v" , AppVersion )
@@ -278,7 +278,7 @@ func main() {
278
278
err := migrator .Migrate ()
279
279
if err != nil {
280
280
migrator .ExecOnFailureHook ()
281
- log .Fatale (err )
281
+ migrationContext . Log .Fatale (err )
282
282
}
283
283
fmt .Fprintf (os .Stdout , "# Done\n " )
284
284
}
0 commit comments