Skip to content

Commit 40978e0

Browse files
committed
[ISSUE-73] fix the beego log config error under windows.
1 parent 607fbf3 commit 40978e0

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

src/qshell/log.go

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package qshell
2+
3+
import (
4+
"encoding/json"
5+
)
6+
7+
type BeeLogConfig struct {
8+
Filename string `json:"filename"`
9+
Level int `json:"level"`
10+
Daily bool `json:"daily"`
11+
MaxDays int `json:"maxdays"`
12+
}
13+
14+
func (c *BeeLogConfig) ToJson() string {
15+
cfgBytes, _ := json.Marshal(c)
16+
return string(cfgBytes)
17+
}

src/qshell/qdownload.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,13 @@ func QiniuDownload(threadCount int, downConfig *DownloadConfig) {
102102
fmt.Println("Writing download log to file", downConfig.LogFile)
103103

104104
//daily rotate
105-
logs.SetLogger(logs.AdapterFile, fmt.Sprintf(`{"filename":"%s", "level":%d, "daily":true, "maxdays":%d}`,
106-
downConfig.LogFile, logLevel, logRotate))
105+
logCfg := BeeLogConfig{
106+
Filename: downConfig.LogFile,
107+
Level: logLevel,
108+
Daily: true,
109+
MaxDays: logRotate,
110+
}
111+
logs.SetLogger(logs.AdapterFile, logCfg.ToJson())
107112
fmt.Println()
108113

109114
logs.Informational("Load account from %s", filepath.Join(QShellRootPath, ".qshell/account.json"))

src/qshell/qupload.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,13 @@ func QiniuUpload(threadCount int, uploadConfig *UploadConfig, watchDir bool) {
170170
fmt.Println("Writing upload log to file", uploadConfig.LogFile)
171171

172172
//daily rotate
173-
logs.SetLogger(logs.AdapterFile, fmt.Sprintf(`{"filename":"%s", "level":%d, "daily":true, "maxdays":%d}`,
174-
uploadConfig.LogFile, logLevel, logRotate))
173+
logCfg := BeeLogConfig{
174+
Filename: uploadConfig.LogFile,
175+
Level: logLevel,
176+
Daily: true,
177+
MaxDays: logRotate,
178+
}
179+
logs.SetLogger(logs.AdapterFile, logCfg.ToJson())
175180
fmt.Println()
176181

177182
//global up settings

0 commit comments

Comments
 (0)