74
74
hclspec .NewLiteral (`"Info"` )),
75
75
"ui_dir" : hclspec .NewDefault (hclspec .NewAttr ("ui_dir" , "string" , false ),
76
76
hclspec .NewLiteral (`""` )),
77
+ "debug_job" : hclspec .NewDefault (hclspec .NewAttr ("debug_job" , "string" , false ),
78
+ hclspec .NewLiteral (`""` )),
77
79
"rsa_private_key_path" : hclspec .NewDefault (hclspec .NewAttr ("rsa_private_key_path" , "string" , false ),
78
80
hclspec .NewLiteral (`""` )),
79
81
"cert_file_path" : hclspec .NewDefault (hclspec .NewAttr ("cert_file_path" , "string" , false ),
@@ -151,9 +153,9 @@ var (
151
153
"SkipIncrementalCopy" : hclspec .NewAttr ("SkipIncrementalCopy" , "bool" , false ),
152
154
"SlaveNetWriteTimeout" : hclspec .NewDefault (hclspec .NewAttr ("SlaveNetWriteTimeout" , "number" , false ),
153
155
hclspec .NewLiteral (`28800` )), // 8 hours
154
- "SrcConnectionConfig" : hclspec .NewBlock ("SrcConnectionConfig" , false , connectionConfigSpec ),
156
+ "SrcConnectionConfig" : hclspec .NewBlock ("SrcConnectionConfig" , false , connectionConfigSpec ),
155
157
"DestConnectionConfig" : hclspec .NewBlock ("DestConnectionConfig" , false , connectionConfigSpec ),
156
- "WaitOnJob" : hclspec .NewAttr ("WaitOnJob" , "string" , false ),
158
+ "WaitOnJob" : hclspec .NewAttr ("WaitOnJob" , "string" , false ),
157
159
"TwoWaySync" : hclspec .NewDefault (hclspec .NewAttr ("TwoWaySync" , "bool" , false ),
158
160
hclspec .NewLiteral (`false` )),
159
161
"BulkInsert1" : hclspec .NewDefault (hclspec .NewAttr ("BulkInsert1" , "number" , false ),
@@ -192,7 +194,7 @@ var (
192
194
hclspec .NewLiteral (`67108864` )),
193
195
"SetGtidNext" : hclspec .NewDefault (hclspec .NewAttr ("SetGtidNext" , "bool" , false ),
194
196
hclspec .NewLiteral (`false` )),
195
- "DestType" : hclspec .NewAttr ("DestType" , "string" , false ),
197
+ "DestType" : hclspec .NewAttr ("DestType" , "string" , false ),
196
198
"SrcOracleConfig" : hclspec .NewBlock ("SrcOracleConfig" , false , oracleConfigSpec ),
197
199
})
198
200
@@ -320,6 +322,7 @@ type DriverConfig struct {
320
322
StatsCollectionInterval int `codec:"stats_collection_interval"`
321
323
PublishMetrics bool `codec:"publish_metrics"`
322
324
LogLevel string `codec:"log_level"`
325
+ DebugJob string `codec:"debug_job"`
323
326
LogFile string `codec:"log_file"`
324
327
UiDir string `codec:"ui_dir"`
325
328
RsaPrivateKeyPath string `codec:"rsa_private_key_path"`
@@ -338,29 +341,13 @@ func (d *Driver) setupLogger() (err error) {
338
341
if d .config .LogFile == "" {
339
342
d .logger .Info ("use nomad logger" , "level" , d .config .LogLevel )
340
343
} else {
341
- err = os .MkdirAll (filepath .Dir (d .config .LogFile ), 0755 )
344
+ err : = os .MkdirAll (filepath .Dir (d .config .LogFile ), 0755 )
342
345
if err != nil {
343
346
return err
344
347
}
345
-
346
- logFileName := d .config .LogFile
347
- if strings .HasSuffix (logFileName , "/" ) {
348
- logFileName += "dtle.log"
349
- }
350
-
351
- rotateFile := & lumberjack.Logger {
352
- Filename : logFileName ,
353
- MaxSize : 512 , // MB
354
- Compress : true ,
355
- }
348
+ d .logger = setupLogger (d .config .LogFile , "dtle.log" )
356
349
357
350
d .logger .Info ("switching to dtle logger" , "file" , d .config .LogFile , "level" , d .config .LogLevel )
358
-
359
- d .logger = hclog .New (& hclog.LoggerOptions {
360
- Name : "" ,
361
- Level : hclog .Info ,
362
- Output : rotateFile ,
363
- })
364
351
g .Logger = d .logger
365
352
366
353
err = d .SetLogLevel (d .config .LogLevel )
@@ -372,6 +359,26 @@ func (d *Driver) setupLogger() (err error) {
372
359
return nil
373
360
}
374
361
362
+ func setupLogger (logFilePath , fileName string ) hclog.Logger {
363
+
364
+ logFileName := logFilePath
365
+ if strings .HasSuffix (logFileName , "/" ) {
366
+ logFileName += fileName
367
+ }
368
+
369
+ rotateFile := & lumberjack.Logger {
370
+ Filename : logFileName ,
371
+ MaxSize : 512 , // MB
372
+ Compress : true ,
373
+ }
374
+
375
+ return hclog .New (& hclog.LoggerOptions {
376
+ Name : "" ,
377
+ Level : hclog .Info ,
378
+ Output : rotateFile ,
379
+ })
380
+ }
381
+
375
382
func (d * Driver ) SetConfig (c * base.Config ) (err error ) {
376
383
if c != nil && c .AgentConfig != nil {
377
384
d .nomadConfig = c .AgentConfig .Driver
@@ -497,7 +504,7 @@ func (d *Driver) Fingerprint(ctx context.Context) (<-chan *drivers.Fingerprint,
497
504
return ch , nil
498
505
}
499
506
500
- //It allows the driver to indicate its health to the client.
507
+ // It allows the driver to indicate its health to the client.
501
508
// The channel returned should immediately send an initial Fingerprint,
502
509
// then send periodic updates at an interval that is appropriate for the driver until the context is canceled.
503
510
func (d * Driver ) handleFingerprint (ctx context.Context , ch chan * drivers.Fingerprint ) {
@@ -515,7 +522,7 @@ func (d *Driver) handleFingerprint(ctx context.Context, ch chan *drivers.Fingerp
515
522
}
516
523
}
517
524
518
- //get the driver status
525
+ // get the driver status
519
526
func (d * Driver ) buildFingerprint () * drivers.Fingerprint {
520
527
521
528
var health drivers.HealthState
@@ -873,6 +880,14 @@ func (d *Driver) SetLogLevel(level string) error {
873
880
return nil
874
881
}
875
882
883
+ func (d * Driver ) ResetDebugJob (job * string ) string {
884
+ if job != nil {
885
+ d .config .DebugJob = * job
886
+ }
887
+
888
+ return d .config .DebugJob
889
+ }
890
+
876
891
func (d * Driver ) SetSetupApiServerFn (fn func (logger g.LoggerType , driverConfig * DriverConfig ) (err error )) {
877
892
d .setupApiServerFn = fn
878
893
}
0 commit comments