change: replace gadb log

This commit is contained in:
debugtalk
2022-12-26 16:49:43 +08:00
parent 869a1b59c3
commit 9b081bff8b
7 changed files with 37 additions and 87 deletions
+4 -5
View File
@@ -8,6 +8,8 @@ import (
"net"
"strconv"
"time"
"github.com/rs/zerolog/log"
)
var ErrConnBroken = errors.New("socket connection broken")
@@ -32,7 +34,7 @@ func newTransport(address string, readTimeout ...time.Duration) (tp transport, e
func (t transport) Send(command string) (err error) {
msg := fmt.Sprintf("%04x%s", len(command), command)
debugLog(fmt.Sprintf("--> %s", command))
log.Debug().Str("cmd", command).Msg("run adb command")
return _send(t.sock, []byte(msg))
}
@@ -42,7 +44,6 @@ func (t transport) VerifyResponse() (err error) {
return err
}
if status == "OKAY" {
debugLog(fmt.Sprintf("<-- %s", status))
return nil
}
@@ -51,7 +52,7 @@ func (t transport) VerifyResponse() (err error) {
return err
}
err = fmt.Errorf("command failed: %s", sError)
debugLog(fmt.Sprintf("<-- %s %s", status, sError))
log.Error().Str("status", status).Str("err", sError).Msg("verify adb response failed")
return
}
@@ -63,7 +64,6 @@ func (t transport) ReadStringAll() (s string, err error) {
func (t transport) ReadBytesAll() (raw []byte, err error) {
raw, err = ioutil.ReadAll(t.sock)
debugLog(fmt.Sprintf("\r%s", raw))
return
}
@@ -84,7 +84,6 @@ func (t transport) UnpackBytes() (raw []byte, err error) {
}
raw, err = t.ReadBytesN(int(size))
debugLog(fmt.Sprintf("\r%s", raw))
return
}