mirror of
https://gitee.com/johng/gf.git
synced 2024-12-01 19:57:40 +08:00
rename Println -> Print for package glog
This commit is contained in:
parent
ac6968edf1
commit
c0c68d1e46
@ -16,10 +16,10 @@ func main() {
|
||||
})
|
||||
s.BindHookHandlerByMap(p, map[string]ghttp.HandlerFunc{
|
||||
ghttp.HookBeforeServe: func(r *ghttp.Request) {
|
||||
glog.To(r.Response.Writer).Println("BeforeServe")
|
||||
glog.To(r.Response.Writer).Print("BeforeServe")
|
||||
},
|
||||
ghttp.HookAfterServe: func(r *ghttp.Request) {
|
||||
glog.To(r.Response.Writer).Println("AfterServe")
|
||||
glog.To(r.Response.Writer).Print("AfterServe")
|
||||
},
|
||||
})
|
||||
s.SetPort(8199)
|
||||
|
@ -25,7 +25,7 @@ func MiddlewareCORS(r *ghttp.Request) {
|
||||
|
||||
func MiddlewareLog(r *ghttp.Request) {
|
||||
r.Middleware.Next()
|
||||
g.Log().Println(r.Response.Status, r.URL.Path)
|
||||
g.Log().Print(r.Response.Status, r.URL.Path)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
@ -23,7 +23,7 @@ func MiddlewareCORS(r *ghttp.Request) {
|
||||
|
||||
func MiddlewareLog(r *ghttp.Request) {
|
||||
r.Middleware.Next()
|
||||
g.Log().Println(r.Response.Status, r.URL.Path)
|
||||
g.Log().Print(r.Response.Status, r.URL.Path)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
func main() {
|
||||
path := "/tmp/glog-cat"
|
||||
g.Log().SetPath(path)
|
||||
g.Log().Stdout(false).Cat("cat1").Cat("cat2").Println("test")
|
||||
g.Log().Stdout(false).Cat("cat1").Cat("cat2").Print("test")
|
||||
list, err := gfile.ScanDir(path, "*", true)
|
||||
g.Dump(err)
|
||||
g.Dump(list)
|
||||
|
@ -12,16 +12,16 @@ func main() {
|
||||
g.Log().SetStdoutPrint(false)
|
||||
|
||||
// 使用默认文件名称格式
|
||||
g.Log().Println("标准文件名称格式,使用当前时间时期")
|
||||
g.Log().Print("标准文件名称格式,使用当前时间时期")
|
||||
|
||||
// 通过SetFile设置文件名称格式
|
||||
g.Log().SetFile("stdout.log")
|
||||
g.Log().Println("设置日志输出文件名称格式为同一个文件")
|
||||
g.Log().Print("设置日志输出文件名称格式为同一个文件")
|
||||
|
||||
// 链式操作设置文件名称格式
|
||||
g.Log().File("stderr.log").Println("支持链式操作")
|
||||
g.Log().File("error-{Ymd}.log").Println("文件名称支持带gtime日期格式")
|
||||
g.Log().File("access-{Ymd}.log").Println("文件名称支持带gtime日期格式")
|
||||
g.Log().File("stderr.log").Print("支持链式操作")
|
||||
g.Log().File("error-{Ymd}.log").Print("文件名称支持带gtime日期格式")
|
||||
g.Log().File("access-{Ymd}.log").Print("文件名称支持带gtime日期格式")
|
||||
|
||||
list, err := gfile.ScanDir(path, "*")
|
||||
g.Dump(err)
|
||||
|
@ -7,9 +7,9 @@ import (
|
||||
|
||||
func main() {
|
||||
g.Log().SetFlags(glog.F_TIME_TIME | glog.F_FILE_SHORT)
|
||||
g.Log().Println("time and short line number")
|
||||
g.Log().Print("time and short line number")
|
||||
g.Log().SetFlags(glog.F_TIME_MILLI | glog.F_FILE_LONG)
|
||||
g.Log().Println("time with millisecond and long line number")
|
||||
g.Log().Print("time with millisecond and long line number")
|
||||
g.Log().SetFlags(glog.F_TIME_STD | glog.F_FILE_LONG)
|
||||
g.Log().Println("standard time format and long line number")
|
||||
g.Log().Print("standard time format and long line number")
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
)
|
||||
|
||||
func PrintLog(content string) {
|
||||
g.Log().Skip(0).Line().Println("line number with skip:", content)
|
||||
g.Log().Line(true).Println("line number without skip:", content)
|
||||
g.Log().Skip(0).Line().Print("line number with skip:", content)
|
||||
g.Log().Line(true).Print("line number without skip:", content)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
func main() {
|
||||
path := "/tmp/glog"
|
||||
g.Log().SetPath(path)
|
||||
g.Log().Println("日志内容")
|
||||
g.Log().Print("日志内容")
|
||||
list, err := gfile.ScanDir(path, "*")
|
||||
g.Dump(err)
|
||||
g.Dump(list)
|
||||
|
@ -12,7 +12,7 @@ func main() {
|
||||
path := "/Users/john/Temp/test"
|
||||
g.Log().SetPath(path)
|
||||
for {
|
||||
g.Log().Println(gtime.Now().String())
|
||||
g.Log().Print(gtime.Now().String())
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ import (
|
||||
|
||||
func main() {
|
||||
g.Log().SetPrefix("[API]")
|
||||
g.Log().Println("hello world")
|
||||
g.Log().Print("hello world")
|
||||
g.Log().Error("error occurred")
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ func main() {
|
||||
for i := 0; i < 3000; i++ {
|
||||
go func() {
|
||||
<-ch
|
||||
g.Log().Println("abcdefghijklmnopqrstuvwxyz1234567890")
|
||||
g.Log().Print("abcdefghijklmnopqrstuvwxyz1234567890")
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
|
@ -26,11 +26,11 @@ func TestCron_Add_Close(t *testing.T) {
|
||||
cron := gcron.New()
|
||||
array := garray.New(true)
|
||||
_, err1 := cron.Add(ctx, "* * * * * *", func(ctx context.Context) {
|
||||
g.Log().Println(ctx, "cron1")
|
||||
g.Log().Print(ctx, "cron1")
|
||||
array.Append(1)
|
||||
})
|
||||
_, err2 := cron.Add(ctx, "* * * * * *", func(ctx context.Context) {
|
||||
g.Log().Println(ctx, "cron2")
|
||||
g.Log().Print(ctx, "cron2")
|
||||
array.Append(1)
|
||||
}, "test")
|
||||
t.Assert(err1, nil)
|
||||
|
@ -24,7 +24,7 @@ func TestCron_Entry_Operations(t *testing.T) {
|
||||
array = garray.New(true)
|
||||
)
|
||||
cron.DelayAddTimes(ctx, 500*time.Millisecond, "* * * * * *", 2, func(ctx context.Context) {
|
||||
g.Log().Println(ctx, "add times")
|
||||
g.Log().Print(ctx, "add times")
|
||||
array.Append(1)
|
||||
})
|
||||
t.Assert(cron.Size(), 0)
|
||||
@ -42,7 +42,7 @@ func TestCron_Entry_Operations(t *testing.T) {
|
||||
array = garray.New(true)
|
||||
)
|
||||
entry, err1 := cron.Add(ctx, "* * * * * *", func(ctx context.Context) {
|
||||
g.Log().Println(ctx, "add")
|
||||
g.Log().Print(ctx, "add")
|
||||
array.Append(1)
|
||||
})
|
||||
t.Assert(err1, nil)
|
||||
@ -56,7 +56,7 @@ func TestCron_Entry_Operations(t *testing.T) {
|
||||
t.Assert(array.Len(), 1)
|
||||
t.Assert(cron.Size(), 1)
|
||||
entry.Start()
|
||||
g.Log().Println(ctx, "start")
|
||||
g.Log().Print(ctx, "start")
|
||||
time.Sleep(1000 * time.Millisecond)
|
||||
t.Assert(array.Len(), 2)
|
||||
t.Assert(cron.Size(), 1)
|
||||
|
Loading…
Reference in New Issue
Block a user