-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprintFinalConfig.go
More file actions
108 lines (97 loc) · 2.32 KB
/
printFinalConfig.go
File metadata and controls
108 lines (97 loc) · 2.32 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
package parser
import (
"fmt"
"strings"
)
// printFinalConfig will print, as a Debug log, the final configuration of the parser
func printFinalConfig(pattern string, config Config, logger LoggerCLI) {
focus := nilFocusStr
if config.Focus != nil {
packagePath, filePath, typeName := "nil", "nil", "nil"
if config.Focus.packagePath != nil {
packagePath = *config.Focus.packagePath
}
if config.Focus.filePath != nil {
filePath = *config.Focus.filePath
}
if config.Focus.typeName != nil {
typeName = *config.Focus.typeName
}
focus = fmt.Sprintf(focusTemplate, packagePath, filePath, typeName)
}
fset := nilFsetStr
if config.Fset != nil {
fset = notNilFsetStr
}
dir := emptyDirStr
if config.Dir != "" {
dir = config.Dir
}
loggerMsg := nilLoggerStr
if config.Logger != nil {
loggerMsg = notNilLoggerStr
}
logFlags := emptyLogFlagsStr
if config.Logger != nil {
logFlags = ignoredLogFlagsStr
} else if config.LogFlags != 0 {
if config.LogFlags&LogJSON != 0 {
logFlags = "LogJSON | "
}
if config.LogFlags&LogTrace != 0 {
logFlags = "LogTrace | "
}
if config.LogFlags&LogDebug != 0 {
logFlags = "LogDebug | "
}
if config.LogFlags&LogInfo != 0 {
logFlags = "LogInfo | "
}
if config.LogFlags&LogWarn != 0 {
logFlags = "LogWarn | "
}
if config.LogFlags&LogError != 0 {
logFlags = "LogError | "
}
if config.LogFlags&LogFatal != 0 {
logFlags = "LogFatal"
}
logFlags = strings.TrimSuffix(logFlags, " | ")
}
logger.Debug(finalConfigTemplate,
pattern,
config.Tests,
dir,
config.Env,
config.BuildFlags,
focus,
fset,
loggerMsg,
logFlags,
)
}
const emptyDirStr = "./"
const nilFsetStr = "Using the FileSet of the library"
const notNilFsetStr = "Using the FileSet provided by the client"
const nilFocusStr = "Focus not defined (will not skip anything)"
const nilLoggerStr = "Logger not defined (will be created using LogFlags)"
const notNilLoggerStr = "Using the Logger instance provided by the client"
const emptyLogFlagsStr = "unset"
const ignoredLogFlagsStr = "Ignored (Logger field is set)"
const finalConfigTemplate = `New GoParser created. Final configuration:
Pattern: %s
Config: {
Tests: %t
Dir: %s
Env: %v
BuildFlags: %v
Focus: %s
Fset: %s
Logger: %s
LogFlags: %s
}`
const focusTemplate = `{
packagePath: %s
filePath: %s
typeName: %s
}`