Skip to content

Commit 5d152e3

Browse files
committed
修复日志输出格式错误的问题
1 parent 5480484 commit 5d152e3

File tree

15 files changed

+92
-90
lines changed

15 files changed

+92
-90
lines changed

common/bean/example_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type TestImpl struct {
1010
}
1111

1212
func (t *TestImpl) DO() {
13-
fmt.Println("do by:", t.name)
13+
log.Debug("do by:", t.name)
1414
}
1515

1616
func init() {
@@ -20,7 +20,7 @@ func init() {
2020
Autowired(&nameInterface)
2121

2222
AddInitializingBeanFunc(func() {
23-
fmt.Println("auto wired done")
23+
log.Debug("auto wired done")
2424
nameInterface.DO()
2525
})
2626

common/dispatcher/dispatch_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func (e *EventServer) TEST(target int) {
1919
select {
2020
case event := <-listener.Event():
2121
index++
22-
fmt.Printf("%d===>%s %s::%s=>%s\n", target, event.Event(), event.Namespace(), event.Key(), string(event.Data()))
22+
log.Debugf("%d===>%s %s::%s=>%s\n", target, event.Event(), event.Namespace(), event.Key(), string(event.Data()))
2323
if index > 3 {
2424
return
2525
}
@@ -73,14 +73,14 @@ func TestDispatcher(t *testing.T) {
7373
select {
7474
case <-tick.C:
7575
index++
76-
fmt.Println("send start", index)
76+
log.Debug("send start", index)
7777
eventServer.Send(&MyEvent{
7878
namespace: "a",
7979
key: "b",
8080
event: "set",
8181
data: []byte(fmt.Sprint(index)),
8282
})
83-
fmt.Println("send end", index)
83+
log.Debug("send end", index)
8484
}
8585
}
8686
}

common/fileLocker/locker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ func (l *Locker) Lock() {
117117
{
118118
err := l.lock(nil)
119119
if err != nil {
120-
fmt.Println("lock file: ", l.path, " error: ", err)
120+
log.Debug("lock file: ", l.path, " error: ", err)
121121
return
122122
}
123-
fmt.Println("lock file: ", l.path, " successfully")
123+
log.Debug("lock file: ", l.path, " successfully")
124124
return
125125
}
126126
case <-lockTimer.C:

context/context_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func Example_Context() {
6969
var httpContext HttpContext
7070
err := ctx.Assert(&httpContext)
7171
if err != nil {
72-
fmt.Println(err)
72+
log.Debug(err)
7373
return
7474
}
7575
// Output:

eoscli/env.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package eoscli
22

33
import (
44
"fmt"
5+
"github.com/eolinker/eosc/log"
56
"strings"
67

78
"github.com/eolinker/eosc/env"
@@ -19,13 +20,13 @@ func Env() *cli.Command {
1920

2021
func EnvFunc(c *cli.Context) error {
2122
for _, name := range env.Envs() {
22-
fmt.Println(env.GenEnv(name, env.GetDefault(name, "")))
23+
log.Debug(env.GenEnv(name, env.GetDefault(name, "")))
2324
}
2425
for k, v := range env.GetConfig() {
2526
if k == "" {
2627
continue
2728
}
28-
fmt.Println(fmt.Sprintf("%s_%s=%s", strings.ToUpper(env.AppName()), k, v))
29+
log.Debug(fmt.Sprintf("%s_%s=%s", strings.ToUpper(env.AppName()), k, v))
2930
}
3031
return nil
3132
}

eoscli/extender.go

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,28 @@ package eoscli
4848
// for _, id := range c.Args().Slice() {
4949
// group, project, _, err := extends.DecodeExtenderId(id)
5050
// if err != nil {
51-
// fmt.Printf("%s is not exists\n", id)
51+
// log.Debugf("%s is not exists\n", id)
5252
// continue
5353
// }
5454
// versions, err := extends.GetAvailableVersions(group, project)
5555
// if err != nil {
56-
// fmt.Printf("%s is not exists\n", id)
56+
// log.Debugf("%s is not exists\n", id)
5757
// continue
5858
// }
59-
// fmt.Printf("[%s]\n", id)
59+
// log.Debugf("[%s]\n", id)
6060
// for i, v := range versions {
6161
// isLatest := ""
6262
// if v.IsLatest {
6363
// isLatest = "(latest)"
6464
// }
6565
// if i != 0 {
66-
// fmt.Printf("\t\t")
66+
// log.Debugf("\t\t")
6767
// } else {
68-
// fmt.Printf(" ")
68+
// log.Debugf(" ")
6969
// }
70-
// fmt.Printf("%s:%s %s", id, v.Version, isLatest)
70+
// log.Debugf("%s:%s %s", id, v.Version, isLatest)
7171
// }
72-
// fmt.Println()
72+
// log.Debug()
7373
// }
7474
//
7575
// return nil
@@ -100,9 +100,9 @@ package eoscli
100100
// }
101101
// all := register.All()
102102
//
103-
// fmt.Println("read:", id)
103+
// log.Debug("read:", id)
104104
// for _, name := range all {
105-
// fmt.Println("\t", name)
105+
// log.Debug("\t", name)
106106
// }
107107
// }
108108
//
@@ -130,7 +130,7 @@ package eoscli
130130
//
131131
//func ExtenderInstall(c *cli.Context) error {
132132
// if c.Args().Len() < 1 {
133-
// fmt.Println("empty extender id list")
133+
// log.Debug("empty extender id list")
134134
// return nil
135135
// }
136136
// pid, err := readPid(env.PidFileDir())
@@ -156,35 +156,35 @@ package eoscli
156156
// }
157157
//
158158
// if len(response.Extends) > 0 {
159-
// fmt.Println("the extender which are installed are below:")
159+
// log.Debug("the extender which are installed are below:")
160160
// for _, ext := range response.Extends {
161-
// fmt.Printf("name:%s\nversion:%s\n", extends.FormatProject(ext.Group, ext.Project), ext.Version)
161+
// log.Debugf("name:%s\nversion:%s\n", extends.FormatProject(ext.Group, ext.Project), ext.Version)
162162
// if len(ext.Plugins) < 1 {
163-
// fmt.Printf("this extender has not plugin\n")
163+
// log.Debugf("this extender has not plugin\n")
164164
// continue
165165
// }
166-
// fmt.Printf("the plugins in extender are below:\n")
166+
// log.Debugf("the plugins in extender are below:\n")
167167
// for _, p := range ext.Plugins {
168-
// fmt.Printf("plugin id:%s\nplugin name:%s\n", p.Id, p.Name)
168+
// log.Debugf("plugin id:%s\nplugin name:%s\n", p.Id, p.Name)
169169
// continue
170170
// }
171171
// }
172172
// }
173173
//
174174
// if len(response.FailExtends) > 0 {
175-
// fmt.Println("the extender which are installed failed are below:")
175+
// log.Debug("the extender which are installed failed are below:")
176176
// for _, ext := range response.FailExtends {
177-
// fmt.Printf("name: %s, reason: %s\n", extends.FormatProject(ext.Group, ext.Project), ext.Msg)
177+
// log.Debugf("name: %s, reason: %s\n", extends.FormatProject(ext.Group, ext.Project), ext.Msg)
178178
// }
179179
// }
180180
//
181-
// fmt.Println("extender install finish")
181+
// log.Debug("extender install finish")
182182
// return nil
183183
//}
184184
//
185185
//func ExtenderUpgrade(c *cli.Context) error {
186186
// if c.Args().Len() < 1 {
187-
// fmt.Println("empty extender id list")
187+
// log.Debug("empty extender id list")
188188
// return nil
189189
// }
190190
// pid, err := readPid(env.PidFileDir())
@@ -207,34 +207,34 @@ package eoscli
207207
// return errors.New(response.Msg)
208208
// }
209209
// if len(response.Extends) > 0 {
210-
// fmt.Println("the extender which are upgraded are below:")
210+
// log.Debug("the extender which are upgraded are below:")
211211
// for _, ext := range response.Extends {
212-
// fmt.Printf("name:%s\nversion:%s\n", extends.FormatProject(ext.Group, ext.Project), ext.Version)
212+
// log.Debugf("name:%s\nversion:%s\n", extends.FormatProject(ext.Group, ext.Project), ext.Version)
213213
// if len(ext.Plugins) < 1 {
214-
// fmt.Printf("the extender has not plugin\n")
214+
// log.Debugf("the extender has not plugin\n")
215215
// continue
216216
// }
217-
// fmt.Printf("the plugins in extender are below:\n")
217+
// log.Debugf("the plugins in extender are below:\n")
218218
// for _, p := range ext.Plugins {
219-
// fmt.Printf("id:%s\nname:%s\n", p.Id, p.Name)
219+
// log.Debugf("id:%s\nname:%s\n", p.Id, p.Name)
220220
// continue
221221
// }
222222
// }
223223
// }
224224
//
225225
// if len(response.FailExtends) > 0 {
226-
// fmt.Println("the extender which are upgraded failed are below:")
226+
// log.Debug("the extender which are upgraded failed are below:")
227227
// for _, ext := range response.FailExtends {
228-
// fmt.Printf("name: %s, reason: %s\n", extends.FormatProject(ext.Group, ext.Project), ext.Msg)
228+
// log.Debugf("name: %s, reason: %s\n", extends.FormatProject(ext.Group, ext.Project), ext.Msg)
229229
// }
230230
// }
231-
// fmt.Println("extender uninstall finish")
231+
// log.Debug("extender uninstall finish")
232232
// return nil
233233
//}
234234
//
235235
//func ExtenderUninstall(c *cli.Context) error {
236236
// if c.Args().Len() < 1 {
237-
// fmt.Println("empty extender id list")
237+
// log.Debug("empty extender id list")
238238
// return nil
239239
// }
240240
// pid, err := readPid(env.PidFileDir())
@@ -257,31 +257,31 @@ package eoscli
257257
// return errors.New(response.Msg)
258258
// }
259259
// if len(response.Extends) < 1 {
260-
// fmt.Printf("extender:%s need not uninstall\n", strings.Join(c.Args().Slice(), ","))
260+
// log.Debugf("extender:%s need not uninstall\n", strings.Join(c.Args().Slice(), ","))
261261
// return nil
262262
// }
263263
// if len(response.Extends) > 0 {
264-
// fmt.Println("the extender which are uninstall are below:")
264+
// log.Debug("the extender which are uninstall are below:")
265265
// for _, ext := range response.Extends {
266-
// fmt.Printf("name:%s\nversion:%s\n", extends.FormatProject(ext.Group, ext.Project), ext.Version)
266+
// log.Debugf("name:%s\nversion:%s\n", extends.FormatProject(ext.Group, ext.Project), ext.Version)
267267
// }
268268
// }
269269
// if len(response.FailExtends) > 0 {
270-
// fmt.Println("the extender which are uninstall failed are below:")
270+
// log.Debug("the extender which are uninstall failed are below:")
271271
// for _, ext := range response.FailExtends {
272-
// fmt.Printf("name: %s, reason: %s\n", extends.FormatProject(ext.Group, ext.Project), ext.Msg)
272+
// log.Debugf("name: %s, reason: %s\n", extends.FormatProject(ext.Group, ext.Project), ext.Msg)
273273
// }
274274
// }
275275
//
276-
// fmt.Println("extender uninstall finish")
276+
// log.Debug("extender uninstall finish")
277277
// return nil
278278
//}
279279
//
280280
//func ExtenderDownload(c *cli.Context) error {
281281
// for _, id := range c.Args().Slice() {
282282
// group, name, version, err := extends.DecodeExtenderId(id)
283283
// if err != nil {
284-
// fmt.Println("decode extender id error:", err, "id is", id)
284+
// log.Debug("decode extender id error:", err, "id is", id)
285285
// continue
286286
// }
287287
// // 当本地不存在当前插件时,从插件市场中下载
@@ -292,7 +292,7 @@ package eoscli
292292
// }
293293
// err = extends.DownLoadToRepository(group, name, version)
294294
// if err != nil {
295-
// fmt.Println("download extender error:", err, "id is", id)
295+
// log.Debug("download extender error:", err, "id is", id)
296296
// continue
297297
// }
298298
// }
@@ -301,7 +301,7 @@ package eoscli
301301
//
302302
//func ExtenderInfo(c *cli.Context) error {
303303
// if c.Args().Len() < 1 {
304-
// fmt.Println("empty extender id list")
304+
// log.Debug("empty extender id list")
305305
// return nil
306306
// }
307307
// for _, id := range c.Args().Slice() {
@@ -320,11 +320,11 @@ package eoscli
320320
// if info.IsLatest {
321321
// isLatest = "(latest)"
322322
// }
323-
// fmt.Printf("name: %s\n", extends.FormatProject(group, project))
324-
// fmt.Printf("version: %s %s\n", info.Version, isLatest)
325-
// fmt.Printf("description:%s\n", info.Description)
326-
// fmt.Printf("download url:%s\n", info.URL)
327-
// fmt.Printf("install to run:%s extender install %s\n", os.Args[0], info.ID)
323+
// log.Debugf("name: %s\n", extends.FormatProject(group, project))
324+
// log.Debugf("version: %s %s\n", info.Version, isLatest)
325+
// log.Debugf("description:%s\n", info.Description)
326+
// log.Debugf("download url:%s\n", info.URL)
327+
// log.Debugf("install to run:%s extender install %s\n", os.Args[0], info.ID)
328328
// }
329329
//
330330
// return nil

eoscli/info.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package eoscli
33
import (
44
"context"
55
"fmt"
6+
"github.com/eolinker/eosc/log"
67
"strings"
78

89
"github.com/eolinker/eosc/env"
@@ -45,6 +46,6 @@ func InfoFunc(c *cli.Context) error {
4546
builder.WriteString(fmt.Sprintf("Term: %d\n", response.Info.Term))
4647
builder.WriteString(fmt.Sprintf("Leader: %d\n", response.Info.LeaderID))
4748

48-
fmt.Println(builder.String())
49+
log.Debug(builder.String())
4950
return nil
5051
}

0 commit comments

Comments
 (0)