diff --git a/builder/oracle/classic/builder.go b/builder/oracle/classic/builder.go index fd084b366..7c682b875 100644 --- a/builder/oracle/classic/builder.go +++ b/builder/oracle/classic/builder.go @@ -3,6 +3,7 @@ package classic import ( "fmt" "log" + "os" "github.com/hashicorp/go-cleanhttp" "github.com/hashicorp/go-oracle-terraform/compute" @@ -35,6 +36,7 @@ func (b *Builder) Prepare(rawConfig ...interface{}) ([]string, error) { func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error) { + loggingEnabled := os.Getenv("PACKER_OCI_CLASSIC_LOGGING")) != "" httpClient := cleanhttp.DefaultClient() config := &opc.Config{ Username: opc.String(b.config.Username), @@ -42,6 +44,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe IdentityDomain: opc.String(b.config.IdentityDomain), APIEndpoint: b.config.apiEndpointURL, LogLevel: opc.LogDebug, + Logger: &Logger{loggingEnabled}, // Logger: # Leave blank to use the default logger, or provide your own HTTPClient: httpClient, } diff --git a/builder/oracle/classic/log.go b/builder/oracle/classic/log.go new file mode 100644 index 000000000..7389dc057 --- /dev/null +++ b/builder/oracle/classic/log.go @@ -0,0 +1,14 @@ +package classic + +import "log" + +type Logger struct { + Enabled bool +} + +func (l *Logger) Log(input ...interface{}) { + if !l.Enabled { + return + } + log.Println(input...) +}