Skip to content

Commit

Permalink
feat: enable hcloud-go debug logging (#167)
Browse files Browse the repository at this point in the history
Packer automatically redirects the output from go `log` to wherever it
needs to be. If users set `PACKER_LOG=1`, the logs will be printed to
`stderr`.


https://developer.hashicorp.com/packer/docs/plugins/creation#logging-and-debugging

Closes #165
  • Loading branch information
apricote authored Apr 22, 2024
1 parent a06056b commit 1ab544e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions builder/hcloud/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package hcloud
import (
"context"
"fmt"
"log"

"github.com/hashicorp/hcl/v2/hcldec"
"github.com/hashicorp/packer-plugin-sdk/communicator"
Expand Down Expand Up @@ -43,6 +44,9 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook)
hcloud.WithEndpoint(b.config.Endpoint),
hcloud.WithBackoffFunc(hcloud.ConstantBackoff(b.config.PollInterval)),
hcloud.WithApplication("hcloud-packer", version.PluginVersion.String()),

// This is being redirect by Packer to the appropriate location. If users set `PACKER_LOG=1` it is shown on stderr
hcloud.WithDebugWriter(log.Writer()),
}
b.hcloudClient = hcloud.NewClient(opts...)
// Set up the state
Expand Down

0 comments on commit 1ab544e

Please sign in to comment.