@@ -46,7 +46,11 @@ type DumpResult struct {
46
46
47
47
// Dump function exports stack data and dumps them as local artifacts, which can be used for debug purposes.
48
48
func Dump (ctx context.Context , options DumpOptions ) ([]DumpResult , error ) {
49
- logger .Debugf ("Dump Elastic stack data" )
49
+ targetPathLogMessage := ""
50
+ if options .Output != "" {
51
+ targetPathLogMessage = fmt .Sprintf (" (location: %s)" , options .Output )
52
+ }
53
+ logger .Debugf ("Dump Elastic stack data%s" , targetPathLogMessage )
50
54
51
55
results , err := dumpStackLogs (ctx , options )
52
56
if err != nil {
@@ -56,12 +60,6 @@ func Dump(ctx context.Context, options DumpOptions) ([]DumpResult, error) {
56
60
}
57
61
58
62
func dumpStackLogs (ctx context.Context , options DumpOptions ) ([]DumpResult , error ) {
59
- logger .Debugf ("Dump stack logs (location: %s)" , options .Output )
60
- err := os .RemoveAll (options .Output )
61
- if err != nil {
62
- return nil , fmt .Errorf ("can't remove output location: %w" , err )
63
- }
64
-
65
63
localServices := & localServicesManager {
66
64
profile : options .Profile ,
67
65
}
@@ -78,6 +76,11 @@ func dumpStackLogs(ctx context.Context, options DumpOptions) ([]DumpResult, erro
78
76
79
77
var logsPath string
80
78
if options .Output != "" {
79
+ err := os .RemoveAll (options .Output )
80
+ if err != nil {
81
+ return nil , fmt .Errorf ("can't remove output location: %w" , err )
82
+ }
83
+
81
84
logsPath = filepath .Join (options .Output , "logs" )
82
85
err = os .MkdirAll (logsPath , 0755 )
83
86
if err != nil {
@@ -91,7 +94,6 @@ func dumpStackLogs(ctx context.Context, options DumpOptions) ([]DumpResult, erro
91
94
if len (options .Services ) > 0 && ! slices .Contains (options .Services , serviceName ) {
92
95
continue
93
96
}
94
-
95
97
logger .Debugf ("Dump stack logs for %s" , serviceName )
96
98
97
99
content , err := dockerComposeLogsSince (ctx , serviceName , options .Profile , options .Since )
0 commit comments