Skip to content

Commit a1a1620

Browse files
committed
change: log all to textarea.
1 parent 7be8d30 commit a1a1620

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

cmd.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const (
3131
func startCmd(config *Config) {
3232
dir, err := os.Getwd()
3333
if err != nil {
34-
log.Println(err)
3534
config.logToTextarea(err.Error())
3635
return
3736
}
@@ -41,10 +40,11 @@ func startCmd(config *Config) {
4140
binPath := ""
4241
if binPath, err = getBinPath(dir); err != nil {
4342
log.Println("get local binary file failed, ", err)
43+
config.logToTextarea("try to download from github.com")
4444

4545
binPath, err = download(config)
4646
if err != nil {
47-
log.Println(err)
47+
config.logToTextarea(err.Error())
4848
return
4949
}
5050
}
@@ -115,7 +115,7 @@ func runCmd(bin string, config *Config) {
115115
}
116116

117117
func download(config *Config) (string, error) {
118-
log.Println("[fetch] fetching latest binary...")
118+
config.logToTextarea("[fetch] fetching latest binary...")
119119
resp, err := http.Get(latestReleaseUrl)
120120
if err != nil {
121121
return "", err
@@ -136,7 +136,9 @@ func download(config *Config) (string, error) {
136136
break
137137
}
138138
}
139-
log.Printf("[fetch] got latest version %s", result.TagName)
139+
140+
config.logToTextarea("[fetch] got latest version " + result.TagName)
141+
140142
r, err := http.Get(obj.BrowserDownloadURL)
141143
if err != nil {
142144
return "", err
@@ -157,14 +159,15 @@ func download(config *Config) (string, error) {
157159
if _, err = io.Copy(out, r.Body); err != nil {
158160
return "", err
159161
}
160-
log.Printf("[fetch] downloaded: %s", obj.Name)
162+
config.logToTextarea("[fetch] downloaded: " + obj.Name)
161163

162164
file, err := os.Open(p)
163165
if err != nil {
164166
return "", err
165167
}
166168

167-
log.Printf("[fetch] prepare to decompress %s", obj.Name)
169+
config.logToTextarea("[fetch] prepare to decompress " + obj.Name)
170+
168171
p, err = extractTar(file, config)
169172
defer file.Close()
170173
if err != nil {
@@ -177,7 +180,7 @@ func download(config *Config) (string, error) {
177180
}
178181
}
179182

180-
log.Printf("[fetch] decompressed")
183+
config.logToTextarea("[fetch] decompressed")
181184
return p, nil
182185
}
183186

kill_win.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
package main
44

55
import (
6-
"log"
76
"os"
87
"os/exec"
98
"strconv"
109
)
1110

1211
func killCmd(config *Config) {
1312
if config.cmd == nil {
14-
log.Println("[kcptun] not running")
1513
config.logToTextarea("[kcptun] not running")
1614
return
1715
}
@@ -20,7 +18,6 @@ func killCmd(config *Config) {
2018
kill.Stderr = os.Stderr
2119
kill.Stdout = os.Stdout
2220
if err := kill.Run(); err != nil {
23-
log.Println(err.Error())
2421
config.logToTextarea("kill cmd: " + err.Error())
2522
return
2623
}

main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var (
3333
var appIcon []byte
3434

3535
func (config *Config) logToTextarea(text string) {
36+
log.Println(text)
3637
config.textEdit.AppendText(text + "\r\n")
3738
}
3839

@@ -66,7 +67,7 @@ func main() {
6667
Text: "Run",
6768
OnClicked: func() {
6869
if config.cmd != nil {
69-
log.Println("current pid is ", config.cmd.Process.Pid)
70+
config.logToTextarea("current pid is " + string(rune(config.cmd.Process.Pid)))
7071
config.logToTextarea("[kcptun] already running.")
7172
return
7273
}

0 commit comments

Comments
 (0)