Can't disable debug messages when using Packer as a library

10 views
Skip to first unread message

Pedro Pereira

unread,
Aug 8, 2019, 3:12:06 PM8/8/19
to Packer
Hey list!

So, I'm using Packer as a library for a little Go project and I'm having trouble with controlling the output of the builds as I can't disable the debug messages.

What I did so far was:
  • Created a Core Config
  • Created a Packer Core based on the Core Config by calling packer.NewCore(config)
  • Created a Build by calling Packer Core's .Build() function
  • Called SetDebug(false) on the build generated on the step above
  • Called Prepare() and then Run()
  • It doesn't matter which type of UI I pass to Run() the debug messages are still shown.
The build process works just fine and an image is created in my GCP account. But I keep seeing multiple debug messages even after calling SetDebug() before calling Prepare(), as instructed by the comments in Packer's source code. For example:
2019/08/08 14:50:01 [DEBUG] Opening new ssh session
2019/08/08 14:50:01 [DEBUG] Starting remote scp process:  scp -vt /tmp
2019/08/08 14:50:01 [DEBUG] Started SCP session, beginning transfers...
2019/08/08 14:50:01 [DEBUG] Copying input data into temporary file so we can read the length
2019/08/08 14:50:01 [DEBUG] scp: Uploading script_7943.sh: perms=C0644 size=61
2019/08/08 14:50:01 [DEBUG] SCP session complete, closing stdin pipe.

Does anybody have any pointers? What am I missing here?

Megan Marsh

unread,
Aug 12, 2019, 2:15:59 PM8/12/19
to packe...@googlegroups.com
Ah. SetDebug is meant to tell the Packer build to run in debug-mode, which means pausing between steps. It doesn't control the debug logging. The debug logging is handled by setting or not setting PACKER_LOG=1, and the behavior is controlled and can be read in `logOutput()` in log.go. 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/8738736e-5aac-4ef3-89bf-48801eacfe14%40googlegroups.com.

Pedro Augusto

unread,
Aug 12, 2019, 3:17:21 PM8/12/19
to packe...@googlegroups.com
Megan,

This helped immensely, thank you!

I was trying to understand why that function wasn't working. All I had to do was configure "log" the way I needed.

Cheers,
Pedro Pereira


Reply all
Reply to author
Forward
0 new messages