/
debuglogging.go
43 lines (40 loc) 路 1.44 KB
/
debuglogging.go
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
package debug
import "fmt"
type LoggingOptions struct {
// LogLevel - choose verbosity level of at least 1 (least verbose).
// If not specified, reverts to default log level.
// Note - These logs may include sensitive information that is provided from your
// execution environment to your cloud provider (and which Pulumi may not even
// itself be aware of).
LogLevel *uint
// LogToStdErr specifies that all logs should be sent directly to stderr - making it
// more accessible and avoiding OS level buffering.
LogToStdErr bool
// FlowToPlugins reflects the logging settings to plugins as well.
FlowToPlugins bool
// Emit tracing to the specified endpoint. Use the file: scheme to write tracing data to a local file
Tracing string
// Print detailed debugging output during resource operations
Debug bool
}
func AddArgs(debugLogOpts *LoggingOptions, sharedArgs []string) []string {
if debugLogOpts.LogToStdErr {
sharedArgs = append(sharedArgs, "--logtostderr")
}
if debugLogOpts.LogLevel != nil {
if *debugLogOpts.LogLevel == 0 {
*debugLogOpts.LogLevel = 1
}
sharedArgs = append(sharedArgs, fmt.Sprintf("-v=%d", *debugLogOpts.LogLevel))
}
if debugLogOpts.FlowToPlugins {
sharedArgs = append(sharedArgs, "--logflow")
}
if debugLogOpts.Tracing != "" {
sharedArgs = append(sharedArgs, fmt.Sprintf("--tracing=%v", debugLogOpts.Tracing))
}
if debugLogOpts.Debug {
sharedArgs = append(sharedArgs, "--debug")
}
return sharedArgs
}