fix: depinject AutoDebug does not save graphviz file (#12297)
This commit is contained in:
parent
2d442b7752
commit
bd31b7c584
@ -79,9 +79,7 @@ func Logger(logger func(string)) DebugOption {
|
||||
})
|
||||
}
|
||||
|
||||
const (
|
||||
debugContainerDot = "debug_container.dot"
|
||||
)
|
||||
const debugContainerDot = "debug_container.dot"
|
||||
|
||||
// Debug is a default debug option which sends log output to stderr, dumps
|
||||
// the container in the graphviz DOT and SVG formats to debug_container.dot
|
||||
@ -155,8 +153,7 @@ func deleteIfExists(filename string) {
|
||||
func DebugOptions(options ...DebugOption) DebugOption {
|
||||
return debugOption(func(c *debugConfig) error {
|
||||
for _, opt := range options {
|
||||
err := opt.applyConfig(c)
|
||||
if err != nil {
|
||||
if err := opt.applyConfig(c); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,6 +31,9 @@ func inject(loc Location, debugOpt DebugOption, config Config, outputs ...interf
|
||||
return err
|
||||
}
|
||||
|
||||
// always generate graph on exit
|
||||
defer cfg.generateGraph()
|
||||
|
||||
// debug cleanup
|
||||
defer func() {
|
||||
for _, f := range cfg.cleanup {
|
||||
@ -38,33 +41,28 @@ func inject(loc Location, debugOpt DebugOption, config Config, outputs ...interf
|
||||
}
|
||||
}()
|
||||
|
||||
err = doInject(cfg, loc, debugOpt, config, outputs...)
|
||||
if err != nil {
|
||||
if err = doInject(cfg, loc, debugOpt, config, outputs...); err != nil {
|
||||
cfg.logf("Error: %v", err)
|
||||
if cfg.onError != nil {
|
||||
err2 := cfg.onError.applyConfig(cfg)
|
||||
if err2 != nil {
|
||||
if err2 := cfg.onError.applyConfig(cfg); err2 != nil {
|
||||
return err2
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
} else {
|
||||
if cfg.onSuccess != nil {
|
||||
err2 := cfg.onSuccess.applyConfig(cfg)
|
||||
if err2 != nil {
|
||||
return err2
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if cfg.onSuccess != nil {
|
||||
if err2 := cfg.onSuccess.applyConfig(cfg); err2 != nil {
|
||||
return err2
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func doInject(cfg *debugConfig, loc Location, debugOpt DebugOption, config Config, outputs ...interface{}) error {
|
||||
defer cfg.generateGraph() // always generate graph on exit
|
||||
|
||||
if debugOpt != nil {
|
||||
err := debugOpt.applyConfig(cfg)
|
||||
if err != nil {
|
||||
if err := debugOpt.applyConfig(cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user