-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprinter.go
More file actions
728 lines (631 loc) · 20.1 KB
/
printer.go
File metadata and controls
728 lines (631 loc) · 20.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
package probe
import (
"bytes"
"fmt"
"io"
"os"
"strings"
"time"
"github.com/briandowns/spinner"
"github.com/fatih/color"
)
// Color Functions
// colorSuccess returns a *color.Color for success (RGB 0,175,0)
func colorSuccess() *color.Color {
return color.RGB(0, 175, 0)
}
// colorError returns a *color.Color for errors (red)
func colorError() *color.Color {
return color.New(color.FgRed)
}
// colorInfo returns a *color.Color for info messages (blue)
func colorInfo() *color.Color {
return color.New(color.FgBlue)
}
// colorDim returns a *color.Color for subdued text
func colorDim() *color.Color {
return color.New(color.FgHiBlack)
}
// colorWarning returns a *color.Color for warnings (yellow)
func colorWarning() *color.Color {
return color.New(color.FgYellow)
}
// colorSkipped returns a *color.Color for skipped items (gray)
func colorSkipped() *color.Color {
return color.New(color.FgHiBlack)
}
func colorNoTest() *color.Color {
return color.RGB(0, 102, 204)
}
// String truncation utilities
const (
// MaxLogStringLength is the maximum length for log output to prevent log bloat
MaxLogStringLength = 200
// MaxStringLength is the maximum length for general string processing
MaxStringLength = 1000000
)
// GetTruncationMessage returns a colored truncation message
func GetTruncationMessage() string {
return "... [" + colorWarning().Sprintf("⚠︎ probe truncated") + "]"
}
// TruncateString truncates a string if it exceeds the maximum length
func TruncateString(s string, maxLen int) string {
if len(s) <= maxLen {
return s
}
return s[:maxLen] + GetTruncationMessage()
}
// TruncateMapStringString truncates long values in map[string]string for logging
func TruncateMapStringString(params map[string]string, maxLen int) map[string]string {
truncated := make(map[string]string)
for key, value := range params {
truncated[key] = TruncateString(value, maxLen)
}
return truncated
}
// TruncateMapStringAny truncates long values in map[string]any for logging
func TruncateMapStringAny(params map[string]any, maxLen int) map[string]any {
truncated := make(map[string]any)
for key, value := range params {
switch v := value.(type) {
case string:
truncated[key] = TruncateString(v, maxLen)
default:
// For non-string values, convert to string first, then truncate
str := fmt.Sprintf("%v", v)
truncated[key] = TruncateString(str, maxLen)
}
}
return truncated
}
// Icon constants
const (
IconSuccess = "✓ "
IconError = "✗ "
IconTriangle = "△ "
IconCircle = "⏺"
IconWait = "🕐︎"
IconSkip = "⏭ "
IconRetry = "⟳"
)
// LogLevel defines different logging levels
type LogLevel int
const (
LogLevelDebug LogLevel = iota
LogLevelInfo
LogLevelWarn
LogLevelError
)
// Printer implements PrintWriter for console print
type Printer struct {
verbose bool
Buffer map[string]*strings.Builder
BufferIDs []string // Order preservation
spinner *spinner.Spinner
outWriter io.Writer
errWriter io.Writer
}
// NewPrinter creates a new console print writer
func NewPrinter(verbose bool, bufferIDs []string) *Printer {
if os.Getenv("FORCE_COLOR") == "1" || os.Getenv("PROBE_TTY") == "1" {
color.NoColor = false
}
buffer := make(map[string]*strings.Builder)
// Pre-initialize buffers for all provided job IDs
for _, id := range bufferIDs {
buffer[id] = &strings.Builder{}
}
s := spinner.New(spinner.CharSets[9], 100*time.Millisecond)
return &Printer{
verbose: verbose,
Buffer: buffer,
BufferIDs: bufferIDs, // Store order information
spinner: s,
outWriter: os.Stdout,
errWriter: os.Stderr,
}
}
func newBufferPrinter() *Printer {
pr := NewPrinter(false, []string{})
pr.outWriter = new(bytes.Buffer)
pr.errWriter = new(bytes.Buffer)
return pr
}
func (p *Printer) StartSpinner() {
if !p.verbose {
p.spinner.Start()
}
}
func (p *Printer) StopSpinner() {
if !p.verbose {
p.spinner.Stop()
}
}
func (p *Printer) AddSpinnerSuffix(txt string) {
if !p.verbose {
p.spinner.Suffix = fmt.Sprintf(" %s...", txt)
}
}
func (p *Printer) Fprint(w io.Writer, a ...any) {
_, err := fmt.Fprint(w, a...)
if err != nil {
fmt.Printf("Fprint: %v\n", err)
}
}
func (p *Printer) Fprintf(w io.Writer, f string, a ...any) {
_, err := fmt.Fprintf(w, f, a...)
if err != nil {
fmt.Printf("Fprintf: %v\n", err)
}
}
func (p *Printer) Fprintln(w io.Writer, a ...any) {
_, err := fmt.Fprintln(w, a...)
if err != nil {
fmt.Printf("Fprintln: %v\n", err)
}
}
// printStepRepeatStart prints the start of a repeated step execution
func (p *Printer) printStepRepeatStart(stepIdx int, stepName string, repeatCount int, output *strings.Builder) {
num := colorDim().Sprintf("%2d.", stepIdx)
p.Fprintf(output, "%s %s (repeating %d times)\n", num, stepName, repeatCount)
}
// printStepRepeatResult prints the final result of a repeated step execution
func (p *Printer) printStepRepeatResult(counter *StepRepeatCounter, hasTest bool, output *strings.Builder) {
totalCount := counter.RepeatTotal
if hasTest {
successRate := float64(counter.SuccessCount) / float64(totalCount) * 100
statusIcon := colorSuccess().Sprintf(IconSuccess)
if counter.FailureCount > 0 {
if counter.SuccessCount == 0 {
statusIcon = colorError().Sprintf(IconError)
} else {
statusIcon = colorNoTest().Sprintf(IconTriangle)
}
}
p.Fprintf(output, " %s %d/%d success (%.1f%%)\n",
statusIcon,
counter.SuccessCount,
totalCount,
successRate)
} else {
// For no test cases, show success count (completed without errors)
statusIcon := colorNoTest().Sprintf(IconTriangle)
if counter.FailureCount > 0 {
statusIcon = colorError().Sprintf(IconError)
}
p.Fprintf(output, " %s %d/%d completed (no test)\n",
statusIcon,
counter.SuccessCount,
totalCount)
}
}
// generateJobResults generates buffered job results as string
func (p *Printer) generateJobResults(jobID string, input string, output *strings.Builder) {
input = strings.TrimSpace(input)
if input != "" {
lines := strings.Split(input, "\n")
for i, line := range lines {
if strings.TrimSpace(line) != "" {
if i == 0 {
p.Fprintf(output, " ⎿ %s\n", line)
} else {
p.Fprintf(output, " %s\n", line)
}
}
}
}
output.WriteString("\n")
}
// generateFooter generates the workflow execution summary as string
func (p *Printer) generateFooter(totalTime float64, successCount, totalJobs int, output *strings.Builder) {
if successCount == totalJobs {
p.Fprintf(output, "Total workflow time: %.2fs %s\n",
totalTime,
colorSuccess().Sprintf(IconSuccess+"All jobs succeeded"))
} else {
failedCount := totalJobs - successCount
p.Fprintf(output, "Total workflow time: %.2fs %s\n",
totalTime,
colorError().Sprintf(IconError+"%d job(s) failed", failedCount))
}
}
// generateJobStatus generates job status line with appropriate icon and color
func (p *Printer) generateJobStatus(jobID, jobName string, status StatusType, duration float64, output *strings.Builder) {
var icon string
var statusText string
var colorFunc func() *color.Color
switch status {
case StatusSuccess:
icon = IconCircle
statusText = fmt.Sprintf("Completed in %.2fs", duration)
colorFunc = colorSuccess
case StatusError:
icon = IconCircle
statusText = fmt.Sprintf("Failed in %.2fs", duration)
colorFunc = colorError
case StatusSkipped:
icon = IconCircle
statusText = "(SKIPPED)"
colorFunc = colorSkipped
default:
icon = IconCircle
statusText = fmt.Sprintf("Unknown status in %.2fs", duration)
colorFunc = colorWarning
}
// For skipped jobs, make the entire line gray
if status == StatusSkipped {
p.Fprintf(output, "%s %s %s\n",
colorFunc().Sprint(icon),
colorFunc().Sprint(jobName),
colorFunc().Sprint(statusText))
} else {
p.Fprintf(output, "%s %s (%s)\n",
colorFunc().Sprint(icon),
jobName,
statusText)
}
}
// GenerateReport generates a complete workflow report string using Result data
func (p *Printer) GenerateReport(rs *Result) string {
if rs == nil {
return ""
}
var output strings.Builder
successCount := 0
var earliestStart, latestEnd time.Time
// Generate step results and job summaries for each job in BufferIDs order
for _, jobID := range p.BufferIDs {
if jr, exists := rs.Jobs[jobID]; exists {
jr.mutex.Lock()
// Calculate job status and duration
duration := jr.EndTime.Sub(jr.StartTime)
// Track earliest start and latest end time for wall clock calculation
if earliestStart.IsZero() || jr.StartTime.Before(earliestStart) {
earliestStart = jr.StartTime
}
if latestEnd.IsZero() || jr.EndTime.After(latestEnd) {
latestEnd = jr.EndTime
}
status := StatusSuccess
if jr.Status == "skipped" {
status = StatusSkipped
successCount++ // Skipped jobs are considered successful
} else if !jr.Success {
status = StatusError
} else {
successCount++
}
// Generate job status output
p.generateJobStatus(jr.JobID, jr.JobName, status, duration.Seconds(), &output)
// Generate job results from StepResults
stepOutput := p.generateJobResultsFromStepResults(jr.StepResults)
p.generateJobResults(jr.JobID, stepOutput, &output)
jr.mutex.Unlock()
}
}
// Calculate actual wall clock time (for parallel jobs)
var totalTime float64
if !earliestStart.IsZero() && !latestEnd.IsZero() {
totalTime = latestEnd.Sub(earliestStart).Seconds()
}
// Generate workflow footer
p.generateFooter(totalTime, successCount, len(rs.Jobs), &output)
return output.String()
}
func (p *Printer) GenerateReportOnlySteps(rs *Result) string {
if rs == nil {
return ""
}
var output strings.Builder
for _, jobID := range p.BufferIDs {
if jr, exists := rs.Jobs[jobID]; exists {
jr.mutex.Lock()
// Generate job results from StepResults
stepOutput := p.generateJobResultsFromStepResults(jr.StepResults)
p.generateJobResults(jr.JobID, stepOutput, &output)
jr.mutex.Unlock()
}
}
return output.String()
}
// PrintReport prints a complete workflow report using Result data
func (p *Printer) PrintReport(rs *Result) {
reportOutput := p.GenerateReport(rs)
if reportOutput != "" {
p.Fprint(p.outWriter, reportOutput)
}
}
// generateJobResultsFromStepResults creates job output string from StepResults
func (p *Printer) generateJobResultsFromStepResults(stepResults []StepResult) string {
if len(stepResults) == 0 {
return ""
}
var output strings.Builder
for _, stepResult := range stepResults {
// Handle repeat steps
if stepResult.RepeatCounter != nil {
p.printStepRepeatStart(stepResult.Index, stepResult.RepeatCounter.Name, stepResult.RepeatCounter.SuccessCount+stepResult.RepeatCounter.FailureCount, &output)
p.printStepRepeatResult(stepResult.RepeatCounter, stepResult.HasTest, &output)
} else {
// Generate regular step output
num := colorDim().Sprintf("%2d.", stepResult.Index)
// Add wait time indicator if present
waitPrefix := ""
if stepResult.WaitTime != "" {
waitPrefix = colorDim().Sprintf("%s%s → ", IconWait, stepResult.WaitTime)
}
// Add suffix: retry info then timing (start time + response time)
ps := ""
if stepResult.RetryAttempt > 0 {
retryColor := colorDim()
if stepResult.RetryAttempt > 1 {
retryColor = colorWarning()
}
ps += retryColor.Sprintf(" %s %d/%d", IconRetry, stepResult.RetryAttempt, stepResult.RetryMax)
}
if !stepResult.StartedAt.IsZero() || stepResult.RT != "" {
timing := ""
if !stepResult.StartedAt.IsZero() {
timing = fmt.Sprintf("@%d", stepResult.StartedAt.Unix())
}
if stepResult.RT != "" {
if timing != "" {
timing += " " + stepResult.RT
} else {
timing = stepResult.RT
}
}
ps += colorDim().Sprintf(" (%s)", timing)
}
switch stepResult.Status {
case StatusSuccess:
p.Fprintf(&output, "%s %s %s%s%s\n", num, colorSuccess().Sprintf(IconSuccess), waitPrefix, stepResult.Name, ps)
case StatusError:
if stepResult.TestOutput != "" {
p.Fprintf(&output, "%s %s %s%s%s\n%s\n", num, colorError().Sprintf(IconError), waitPrefix, stepResult.Name, ps, stepResult.TestOutput)
} else {
p.Fprintf(&output, "%s %s %s%s%s\n", num, colorError().Sprintf(IconError), waitPrefix, stepResult.Name, ps)
}
case StatusWarning:
p.Fprintf(&output, "%s %s %s%s%s\n", num, colorNoTest().Sprintf(IconTriangle), waitPrefix, stepResult.Name, ps)
case StatusSkipped:
p.Fprintf(&output, "%s %s %s%s%s\n", num, colorInfo().Sprintf(IconSkip), waitPrefix, colorDim().Sprintf("%s", stepResult.Name), ps)
}
if stepResult.Report != "" {
a5space := " "
re := strings.ReplaceAll(stepResult.Report, "\n", "\n"+a5space)
re = strings.TrimRight(re, " \n\t\r")
output.WriteString(a5space + re + "\n")
}
if stepResult.EchoOutput != "" {
// NOTE:
// If you apply an ANSI reset code to a string that contains line breaks, the Trim methods will no longer work as expected.
// Therefore, remove the trailing line breaks first, then apply the color settings and finally add the line break.
echo := strings.TrimRight(stepResult.EchoOutput, " \n\t\r")
output.WriteString(colorInfo().Sprint(echo) + "\n")
}
}
}
return output.String()
}
// generateHeader generates the workflow header string
func (p *Printer) generateHeader(name, description string) string {
if name == "" {
return ""
}
var output strings.Builder
bold := color.New(color.Bold)
output.WriteString(bold.Sprintf("%s\n", name))
if description != "" {
output.WriteString(colorDim().Sprintf("%s\n", description))
}
output.WriteString("\n")
return output.String()
}
// PrintHeader prints the workflow name and description
func (p *Printer) PrintHeader(name, description string) {
header := p.generateHeader(name, description)
if header != "" {
p.Fprint(p.outWriter, header)
}
}
// generateError generates an error message string
func (p *Printer) generateError(format string, args ...any) string {
return fmt.Sprintf("%s: %s\n", colorError().Sprintf("Error"), fmt.Sprintf(format, args...))
}
// PrintError prints an error message
func (p *Printer) PrintError(format string, args ...any) {
p.Fprint(p.errWriter, p.generateError(format, args...))
}
// PrintVerbose prints verbose output (only if verbose mode is enabled)
func (p *Printer) PrintVerbose(format string, args ...any) {
if p.verbose {
p.Fprintf(p.errWriter, format, args...)
}
}
// PrintSeparator prints a separator line for verbose output
func (p *Printer) PrintSeparator() {
if p.verbose {
p.Fprintln(p.errWriter, "- - -")
}
}
// generateLogDebug generates debug message string
func (p *Printer) generateLogDebug(format string, args ...any) string {
return fmt.Sprintf("[DEBUG] %s\n", fmt.Sprintf(format, args...))
}
// LogDebug prints debug messages (only in verbose mode)
func (p *Printer) LogDebug(format string, args ...any) {
if p.verbose {
p.Fprint(p.errWriter, p.generateLogDebug(format, args...))
}
}
// generateLogError generates error log message string
func (p *Printer) generateLogError(format string, args ...any) string {
return fmt.Sprintf("%s\n", colorError().Sprintf("[ERROR] %s", fmt.Sprintf(format, args...)))
}
// LogError prints error messages to stderr
func (p *Printer) LogError(format string, args ...any) {
p.Fprint(os.Stderr, p.generateLogError(format, args...))
}
// Step Output Formatting Functions
// These functions handle output formatting with proper separation of concerns
// generateEchoOutput formats echo output with proper indentation
func (p *Printer) generateEchoOutput(content string, err error) string {
if err != nil {
return fmt.Sprintf("Echo\nerror: %#v\n", err)
}
// Add indent to all lines, including after user-specified newlines
indent := " "
lines := strings.Split(strings.TrimSpace(content), "\n")
indentedLines := make([]string, len(lines))
for i, line := range lines {
indentedLines[i] = indent + line
}
return strings.Join(indentedLines, "\n") + "\n"
}
// generateTestFailure formats test failure output with request/response info
func (p *Printer) generateTestFailure(testExpr string, result any, req, res map[string]any) string {
// Check if response has dump field set to false
if res != nil {
if dump, exists := res["dump"]; exists {
if dumpBool, ok := dump.(bool); ok && !dumpBool {
return "" // Don't dump request/response if dump is false
}
}
}
output := fmt.Sprintf(" %s %#v\n", colorInfo().Sprintf("request:"), req)
output += fmt.Sprintf(" %s %#v\n", colorInfo().Sprintf("response:"), res)
return output
}
// generateTestError formats test evaluation error output
func (p *Printer) generateTestError(testExpr string, err error) string {
if p.verbose {
p.LogError("Test Error: %s", err)
p.LogError("Input: %s", testExpr)
}
return fmt.Sprintf("Test\nerror: %#v\n", err)
}
// generateTestTypeMismatch formats test type mismatch error output
func (p *Printer) generateTestTypeMismatch(testExpr string, result any) string {
txt := fmt.Sprintf("Test: `%s` = %v\n", testExpr, result)
if p.verbose {
p.LogDebug("%s", txt)
}
return txt
}
// PrintTestResult prints test result in verbose mode
func (p *Printer) PrintTestResult(success bool, testExpr string, context any) {
var resultStr string
if success {
resultStr = colorSuccess().Sprintf("Success")
} else {
resultStr = colorError().Sprintf("Failure")
}
p.LogDebug("Test: %s (input: %s, env: %s)", resultStr, testExpr, colorDim().Sprintf("%#v", context))
}
// PrintEchoContent prints echo content with proper indentation in verbose mode
func (p *Printer) PrintEchoContent(content string) {
// Add indent to all lines, including after user-specified newlines
indent := " "
lines := strings.SplitSeq(content, "\n")
for line := range lines {
p.LogDebug("%s%s", indent, line)
}
}
// PrintRequestResponse prints request and response data with proper formatting
func (p *Printer) PrintRequestResponse(stepIdx int, stepName string, req, res map[string]any, rt string) {
p.LogDebug("%s", colorWarning().Sprintf("--- Step %d: %s", stepIdx, stepName))
p.LogDebug("Request:")
p.PrintMapData(req)
p.LogDebug("Response:")
p.PrintMapData(res)
p.LogDebug("RT: %s", colorInfo().Sprintf("%s", rt))
}
// PrintMapData prints map data with proper formatting for nested structures
func (p *Printer) PrintMapData(data map[string]any) {
p.printMapDataRecursive(data, 1)
}
// printMapDataRecursive recursively prints map data with YAML-like indentation
func (p *Printer) printMapDataRecursive(data map[string]any, indentLevel int) {
indent := strings.Repeat(" ", indentLevel)
for k, v := range data {
switch val := v.(type) {
case map[string]any:
if len(val) == 0 {
p.LogDebug("%s%s: {}", indent, k)
} else {
p.LogDebug("%s%s:", indent, k)
p.printMapDataRecursive(val, indentLevel+1)
}
case []any:
if len(val) == 0 {
p.LogDebug("%s%s: []", indent, k)
} else {
p.LogDebug("%s%s:", indent, k)
p.printSliceRecursive(val, indentLevel+1)
}
case map[string]string:
if len(val) == 0 {
p.LogDebug("%s%s: {}", indent, k)
} else {
p.LogDebug("%s%s:", indent, k)
for kk, vv := range val {
p.LogDebug("%s %s: %v", indent, kk, vv)
}
}
case []string:
if len(val) == 0 {
p.LogDebug("%s%s: []", indent, k)
} else {
p.LogDebug("%s%s:", indent, k)
for _, item := range val {
p.LogDebug("%s- %v", indent+" ", item)
}
}
default:
p.LogDebug("%s%s: %v", indent, k, v)
}
}
}
// printSliceRecursive recursively prints slice data with YAML-like indentation
func (p *Printer) printSliceRecursive(data []any, indentLevel int) {
indent := strings.Repeat(" ", indentLevel)
for _, v := range data {
switch val := v.(type) {
case map[string]any:
if len(val) == 0 {
p.LogDebug("%s- {}", indent)
} else {
p.LogDebug("%s-", indent)
p.printMapDataRecursive(val, indentLevel+1)
}
case []any:
if len(val) == 0 {
p.LogDebug("%s- []", indent)
} else {
p.LogDebug("%s-", indent)
p.printSliceRecursive(val, indentLevel+1)
}
case map[string]string:
if len(val) == 0 {
p.LogDebug("%s- {}", indent)
} else {
p.LogDebug("%s-", indent)
for kk, vv := range val {
p.LogDebug("%s %s: %v", indent, kk, vv)
}
}
case []string:
if len(val) == 0 {
p.LogDebug("%s- []", indent)
} else {
p.LogDebug("%s-", indent)
for _, item := range val {
p.LogDebug("%s - %v", indent, item)
}
}
default:
p.LogDebug("%s- %v", indent, v)
}
}
}