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