Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c079b96

Browse files
Add more verbose logging for upload endpoint
1 parent 09f7dc1 commit c079b96

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

‎main.go‎

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io"
88
"io/ioutil"
99
"net/http"
10+
"net/http/httptrace"
1011
"os"
1112
"regexp"
1213
"strconv"
@@ -114,10 +115,6 @@ func main() {
114115
}
115116

116117
if *uploadEndpoint != "" {
117-
if *verbose {
118-
fmt.Println("Uploading the sketch")
119-
}
120-
121118
f, err := os.Open(*sketchPath)
122119
if err != nil {
123120
if *verbose {
@@ -156,6 +153,32 @@ func main() {
156153
req.SetBasicAuth(*username, *password)
157154
}
158155

156+
if *verbose {
157+
trace := &httptrace.ClientTrace{
158+
ConnectStart: func(network, addr string) {
159+
fmt.Print("Connecting to board ... ")
160+
},
161+
ConnectDone: func(network, addr string, err error) {
162+
if err != nil {
163+
fmt.Println("failed!")
164+
} else {
165+
fmt.Println(" done")
166+
}
167+
},
168+
WroteHeaders: func() {
169+
fmt.Print("Uploading sketch ... ")
170+
},
171+
WroteRequest: func(wri httptrace.WroteRequestInfo) {
172+
fmt.Println(" done")
173+
fmt.Print("Flashing sketch ... ")
174+
},
175+
GotFirstResponseByte: func() {
176+
fmt.Println(" done")
177+
},
178+
}
179+
req = req.WithContext(httptrace.WithClientTrace(req.Context(), trace))
180+
}
181+
159182
resp, err := httpClient.Do(req)
160183
if err != nil {
161184
if *verbose {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /