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 flag added and optional logging #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ _testmain.go
*.exe
*.test
*.prof

.idea/
5 changes: 4 additions & 1 deletion adbutility/adbutility.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
// AdbEndpoint struct defines an adb communication endpoint for an android device.
type AdbEndpoint struct {
ADBPath string // Executable path of adb command
Debug bool // Logs some events if enabled
}

// GetNewAdbEndpoint method returns a new ADBEndpoint instance with specified adb
Expand Down Expand Up @@ -39,7 +40,9 @@ type AdbEndpointOutputChannel chan AdbEndpointOutput
// representing the adb command output including stdout and stderr and error is
// returned if something went wrong.
func (ep AdbEndpoint) Adb(timeout int, args ...string) (string, error) {
log.Println("adb :", args)
if ep.Debug {
log.Println("adb :", args)
}
cmd := exec.Command(ep.ADBPath, args...)
done := make(AdbEndpointOutputChannel)
go func(done AdbEndpointOutputChannel, cmd *exec.Cmd) {
Expand Down