Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug Update to Add a Password Scrubber and stdout style LogType #1648

Merged
merged 1 commit into from
Oct 4, 2019

Conversation

luthermonson
Copy link
Contributor

@luthermonson luthermonson commented Oct 3, 2019

Most important part of this PR is the Scrub method added to the debug output to remove your password from the logs. To do this I just wrote a wrapper CloseWrite for FileType and to debug easier I wrote a LogType so decided to include it in the PR.

LogType uses go's log package and fakes a write/close to pass to the TeeReader and instead run a log.Print() on the contents which are normally written to file. This will show debug in your console while the command is running. @dougm would love your feedback as output is a bit messy but I didn't want to rock the boat too hard and kept some of file output like filename etc.

I additionally added a -debug to default to the stdout LogType method if no GOVC_DEBUG_PATH is not set so you don't magically write some log files without the govc user knowing (which happened to me)

@luthermonson
Copy link
Contributor Author

ah crap i commited my build binary.. fixing

@luthermonson
Copy link
Contributor Author

removed binary and force pushed, sorry about that.

Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @luthermonson , +1 to both scrubbing the password and having a stderr option for -debug. Just don't want to change the existing behavior, -debug alone should still default to using ~/.govmomi/debug

govc/flags/debug.go Show resolved Hide resolved
vim25/debug/debug.go Outdated Show resolved Hide resolved
vim25/debug/debug.go Outdated Show resolved Hide resolved
vim25/debug/file.go Show resolved Hide resolved
vim25/debug/log.go Show resolved Hide resolved
@luthermonson
Copy link
Contributor Author

@dougm updated per feedback and rebased to one commit and force pushed

@luthermonson
Copy link
Contributor Author

@dougm added readme update to deocument -debug since its looking like youre going to merge this.

@dougm
Copy link
Member

dougm commented Oct 4, 2019

Thanks @luthermonson , esp. for adding the long overdue docs. Keep in mind that debug also works with json (tags, content library, etc). Personally I always have:

% env | grep GOVC_DEBUG
GOVC_DEBUG_PATH_RUN=last
GOVC_DEBUG=true

And the I run $GOPATH/src/github.com/vmware/govmomi/scripts/debug-xmlformat.sh to view request/response logs.

I think it'd be awesome to have GOVC_DEBUG_PATH=- pretty-print the output as debug-xmlformat.sh does, but using Go's json + xml pretty printers. But that could be addressed in a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants