Merge pull request #5042 from hashicorp/fix5028
Don't do any logging in real main
This commit is contained in:
commit
2c8943a12d
11
main.go
11
main.go
|
@ -53,6 +53,9 @@ func realMain() int {
|
|||
logWriter = ioutil.Discard
|
||||
}
|
||||
|
||||
// Disable logging here
|
||||
log.SetOutput(ioutil.Discard)
|
||||
|
||||
// We always send logs to a temporary file that we use in case
|
||||
// there is a panic. Otherwise, we delete it.
|
||||
logTempFile, err := ioutil.TempFile("", "packer-log")
|
||||
|
@ -74,13 +77,7 @@ func realMain() int {
|
|||
go copyOutput(outR, doneCh)
|
||||
|
||||
// Enable checkpoint for panic reporting
|
||||
config, err := loadConfig()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Couldn't load config: %s", err)
|
||||
return 1
|
||||
}
|
||||
|
||||
if !config.DisableCheckpoint {
|
||||
if config, _ := loadConfig(); config != nil && !config.DisableCheckpoint {
|
||||
packer.CheckpointReporter.Enable(config.DisableCheckpointSignature)
|
||||
}
|
||||
|
||||
|
|
|
@ -37,13 +37,13 @@ type CheckpointTelemetry struct {
|
|||
func (c *CheckpointTelemetry) Enable(disableSignature bool) {
|
||||
configDir, err := ConfigDir()
|
||||
if err != nil {
|
||||
log.Printf("[ERR] Checkpoint telemetry setup error: %s", err)
|
||||
log.Printf("[WARN] (telemetry) setup error: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
signatureFile := ""
|
||||
if disableSignature {
|
||||
log.Printf("[INFO] Checkpoint telemetry signature disabled")
|
||||
log.Printf("[INFO] (telemetry) Checkpoint signature disabled")
|
||||
} else {
|
||||
signatureFile = filepath.Join(configDir, "checkpoint_signature")
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ func (c *CheckpointTelemetry) ReportPanic(m string) error {
|
|||
}
|
||||
|
||||
func (c *CheckpointTelemetry) AddSpan(name, pluginType string) *TelemetrySpan {
|
||||
log.Printf("[TELEMETRY] Starting %s %s", pluginType, name)
|
||||
log.Printf("[INFO] (telemetry) Starting %s %s", pluginType, name)
|
||||
ts := &TelemetrySpan{
|
||||
Name: name,
|
||||
Type: pluginType,
|
||||
|
@ -127,9 +127,9 @@ type TelemetrySpan struct {
|
|||
|
||||
func (s *TelemetrySpan) End(err error) {
|
||||
s.EndTime = time.Now().UTC()
|
||||
log.Printf("[TELEMETRY] ending %s", s.Name)
|
||||
log.Printf("[INFO] (telemetry) ending %s", s.Name)
|
||||
if err != nil {
|
||||
s.Error = err.Error()
|
||||
log.Printf("[TELEMETRY] ERROR: %s", err.Error())
|
||||
log.Printf("[INFO] (telemetry) found error: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue