diff --git a/.example/container/gpool/gpool_expirefunc.go b/.example/container/gpool/gpool_expirefunc.go index fa87cd1e8..36ded0980 100644 --- a/.example/container/gpool/gpool_expirefunc.go +++ b/.example/container/gpool/gpool_expirefunc.go @@ -14,7 +14,7 @@ func main() { p := gpool.New(3000*time.Millisecond, func() (interface{}, error) { return gtcp.NewConn("www.baidu.com:80") }, func(i interface{}) { - glog.Println("expired") + glog.Print("expired") i.(*gtcp.Conn).Close() }) conn, err := p.Get() diff --git a/.example/errors/gerror/gerror5.go b/.example/errors/gerror/gerror5.go index 191965789..56426ae37 100644 --- a/.example/errors/gerror/gerror5.go +++ b/.example/errors/gerror/gerror5.go @@ -17,6 +17,6 @@ func Error2() error { } func main() { - glog.Println(Error1()) - glog.Println(Error2()) + glog.Print(Error1()) + glog.Print(Error2()) } diff --git a/.example/net/ghttp/server/cors/cors1.go b/.example/net/ghttp/server/cors/cors1.go index 655a8da2f..03c50b6aa 100644 --- a/.example/net/ghttp/server/cors/cors1.go +++ b/.example/net/ghttp/server/cors/cors1.go @@ -12,7 +12,7 @@ func MiddlewareCORS(r *ghttp.Request) { } func Order(r *ghttp.Request) { - glog.Println("order") + glog.Print("order") r.Response.Write("GET") } diff --git a/.example/net/ghttp/server/hooks/hooks1.go b/.example/net/ghttp/server/hooks/hooks1.go index 492be6514..817a11eca 100644 --- a/.example/net/ghttp/server/hooks/hooks1.go +++ b/.example/net/ghttp/server/hooks/hooks1.go @@ -11,10 +11,10 @@ func main() { p := "/:name/info/{uid}" s := g.Server() s.BindHookHandlerByMap(p, map[string]ghttp.HandlerFunc{ - ghttp.HookBeforeServe: func(r *ghttp.Request) { glog.Println(ghttp.HookBeforeServe) }, - ghttp.HookAfterServe: func(r *ghttp.Request) { glog.Println(ghttp.HookAfterServe) }, - ghttp.HookBeforeOutput: func(r *ghttp.Request) { glog.Println(ghttp.HookBeforeOutput) }, - ghttp.HookAfterOutput: func(r *ghttp.Request) { glog.Println(ghttp.HookAfterOutput) }, + ghttp.HookBeforeServe: func(r *ghttp.Request) { glog.Print(ghttp.HookBeforeServe) }, + ghttp.HookAfterServe: func(r *ghttp.Request) { glog.Print(ghttp.HookAfterServe) }, + ghttp.HookBeforeOutput: func(r *ghttp.Request) { glog.Print(ghttp.HookBeforeOutput) }, + ghttp.HookAfterOutput: func(r *ghttp.Request) { glog.Print(ghttp.HookAfterOutput) }, }) s.BindHandler(p, func(r *ghttp.Request) { r.Response.Write("用户:", r.Get("name"), ", uid:", r.Get("uid")) diff --git a/.example/net/ghttp/server/reuseport/reuseport.go b/.example/net/ghttp/server/reuseport/reuseport.go index 538b38e34..1cd27b919 100644 --- a/.example/net/ghttp/server/reuseport/reuseport.go +++ b/.example/net/ghttp/server/reuseport/reuseport.go @@ -10,7 +10,7 @@ func main() { s1 := ghttp.GetServer("s1") s1.SetPort(8882) s1.BindHandler("/", func(r *ghttp.Request) { - glog.Println("s1") + glog.Print("s1") r.Response.Writeln("s1") }) s1.Start() @@ -18,7 +18,7 @@ func main() { s2 := ghttp.GetServer("s2") s2.SetPort(8882) s2.BindHandler("/", func(r *ghttp.Request) { - glog.Println("s2") + glog.Print("s2") r.Response.Writeln("s2") }) s2.Start() diff --git a/.example/net/gtcp/pkg_operations/common/gtcp_common_client.go b/.example/net/gtcp/pkg_operations/common/gtcp_common_client.go index 6ccf1137a..160878d39 100644 --- a/.example/net/gtcp/pkg_operations/common/gtcp_common_client.go +++ b/.example/net/gtcp/pkg_operations/common/gtcp_common_client.go @@ -32,7 +32,7 @@ func main() { msg, err := funcs.RecvPkg(conn) if err != nil { if err.Error() == "EOF" { - glog.Println("server closed") + glog.Print("server closed") } break } diff --git a/.example/net/gtcp/pkg_operations/common/gtcp_common_server.go b/.example/net/gtcp/pkg_operations/common/gtcp_common_server.go index 7a6b23b21..b335db92e 100644 --- a/.example/net/gtcp/pkg_operations/common/gtcp_common_server.go +++ b/.example/net/gtcp/pkg_operations/common/gtcp_common_server.go @@ -21,7 +21,7 @@ func main() { msg, err := funcs.RecvPkg(conn) if err != nil { if err.Error() == "EOF" { - glog.Println("client closed") + glog.Print("client closed") } break } diff --git a/.example/net/gtcp/pkg_operations/monitor/gtcp_monitor_client.go b/.example/net/gtcp/pkg_operations/monitor/gtcp_monitor_client.go index da316425f..6f150f410 100644 --- a/.example/net/gtcp/pkg_operations/monitor/gtcp_monitor_client.go +++ b/.example/net/gtcp/pkg_operations/monitor/gtcp_monitor_client.go @@ -35,9 +35,9 @@ func main() { // 使用 SendRecvPkg 发送消息包并接受返回 if result, err := conn.SendRecvPkg(info); err != nil { if err.Error() == "EOF" { - glog.Println("server closed") + glog.Print("server closed") } } else { - glog.Println(string(result)) + glog.Print(string(result)) } } diff --git a/.example/net/gtcp/pkg_operations/monitor/gtcp_monitor_server.go b/.example/net/gtcp/pkg_operations/monitor/gtcp_monitor_server.go index 02606676f..056c0a498 100644 --- a/.example/net/gtcp/pkg_operations/monitor/gtcp_monitor_server.go +++ b/.example/net/gtcp/pkg_operations/monitor/gtcp_monitor_server.go @@ -16,7 +16,7 @@ func main() { data, err := conn.RecvPkg() if err != nil { if err.Error() == "EOF" { - glog.Println("client closed") + glog.Print("client closed") } break } @@ -24,7 +24,7 @@ func main() { if err := json.Unmarshal(data, info); err != nil { glog.Errorf("invalid package structure: %s", err.Error()) } else { - glog.Println(info) + glog.Print(info) conn.SendPkg([]byte("ok")) } } diff --git a/.example/os/gcron/gcron-log.go b/.example/os/gcron/gcron-log.go index 1a6fc0f10..d77aa1a4b 100644 --- a/.example/os/gcron/gcron-log.go +++ b/.example/os/gcron/gcron-log.go @@ -10,7 +10,7 @@ import ( func main() { gcron.SetLogLevel(glog.LEVEL_ALL) gcron.Add("* * * * * ?", func() { - glog.Println("test") + glog.Print("test") }) time.Sleep(3 * time.Second) } diff --git a/.example/os/gcron/gcron1.go b/.example/os/gcron/gcron1.go index ecac47837..6b90aec61 100644 --- a/.example/os/gcron/gcron1.go +++ b/.example/os/gcron/gcron1.go @@ -8,14 +8,14 @@ import ( ) func main() { - gcron.Add("0 30 * * * *", func() { glog.Println("Every hour on the half hour") }) - gcron.Add("* * * * * *", func() { glog.Println("Every second, pattern") }, "second-cron") - gcron.Add("*/5 * * * * *", func() { glog.Println("Every 5 seconds, pattern") }) + gcron.Add("0 30 * * * *", func() { glog.Print("Every hour on the half hour") }) + gcron.Add("* * * * * *", func() { glog.Print("Every second, pattern") }, "second-cron") + gcron.Add("*/5 * * * * *", func() { glog.Print("Every 5 seconds, pattern") }) - gcron.Add("@hourly", func() { glog.Println("Every hour") }) - gcron.Add("@every 1h30m", func() { glog.Println("Every hour thirty") }) - gcron.Add("@every 1s", func() { glog.Println("Every 1 second") }) - gcron.Add("@every 5s", func() { glog.Println("Every 5 seconds") }) + gcron.Add("@hourly", func() { glog.Print("Every hour") }) + gcron.Add("@every 1h30m", func() { glog.Print("Every hour thirty") }) + gcron.Add("@every 1s", func() { glog.Print("Every 1 second") }) + gcron.Add("@every 5s", func() { glog.Print("Every 5 seconds") }) time.Sleep(3 * time.Second) diff --git a/.example/os/gcron/gcron2.go b/.example/os/gcron/gcron2.go index 59589937f..bc032dba1 100644 --- a/.example/os/gcron/gcron2.go +++ b/.example/os/gcron/gcron2.go @@ -8,7 +8,7 @@ import ( ) func test() { - glog.Println(111) + glog.Print(111) } func main() { diff --git a/.example/os/gfsnotify/fsnotify.go b/.example/os/gfsnotify/fsnotify.go index 9df3a45f5..833732398 100644 --- a/.example/os/gfsnotify/fsnotify.go +++ b/.example/os/gfsnotify/fsnotify.go @@ -1,6 +1,7 @@ package main import ( + "context" "log" "github.com/fsnotify/fsnotify" @@ -25,7 +26,7 @@ func main() { for { select { case ev := <-watch.Events: - glog.Println(ev) + glog.Print(context.Background(), ev) case err := <-watch.Errors: log.Println("error : ", err) diff --git a/.example/os/gfsnotify/gfsnotify.go b/.example/os/gfsnotify/gfsnotify.go index ec09728a3..deedea686 100644 --- a/.example/os/gfsnotify/gfsnotify.go +++ b/.example/os/gfsnotify/gfsnotify.go @@ -9,7 +9,7 @@ func main() { //path := `D:\temp` path := "/Users/john/Temp" _, err := gfsnotify.Add(path, func(event *gfsnotify.Event) { - glog.Println(event) + glog.Print(event) }) if err != nil { glog.Fatal(err) diff --git a/.example/os/gfsnotify/gfsnotify_callback.go b/.example/os/gfsnotify/gfsnotify_callback.go index de66de371..f6e864d9e 100644 --- a/.example/os/gfsnotify/gfsnotify_callback.go +++ b/.example/os/gfsnotify/gfsnotify_callback.go @@ -10,13 +10,13 @@ import ( func main() { c1, err := gfsnotify.Add("/home/john/temp/log", func(event *gfsnotify.Event) { - glog.Println("callback1") + glog.Print("callback1") }) if err != nil { panic(err) } c2, err := gfsnotify.Add("/home/john/temp/log", func(event *gfsnotify.Event) { - glog.Println("callback2") + glog.Print("callback2") }) if err != nil { panic(err) @@ -24,12 +24,12 @@ func main() { // 5秒后移除c1的回调函数注册,仅剩c2 gtimer.SetTimeout(5*time.Second, func() { gfsnotify.RemoveCallback(c1.Id) - glog.Println("remove callback c1") + glog.Print("remove callback c1") }) // 10秒后移除c2的回调函数注册,所有的回调都移除,不再有任何打印信息输出 gtimer.SetTimeout(10*time.Second, func() { gfsnotify.RemoveCallback(c2.Id) - glog.Println("remove callback c2") + glog.Print("remove callback c2") }) select {} diff --git a/.example/os/gfsnotify/gfsnotify_callback_folder.go b/.example/os/gfsnotify/gfsnotify_callback_folder.go index f41e83a21..7165fddbd 100644 --- a/.example/os/gfsnotify/gfsnotify_callback_folder.go +++ b/.example/os/gfsnotify/gfsnotify_callback_folder.go @@ -10,7 +10,7 @@ import ( func main() { callback, err := gfsnotify.Add("/home/john/temp", func(event *gfsnotify.Event) { - glog.Println("callback") + glog.Print("callback") }) if err != nil { panic(err) @@ -21,7 +21,7 @@ func main() { // 20秒后移除回调函数注册,所有的回调都移除,不再有任何打印信息输出 gtimer.SetTimeout(20*time.Second, func() { gfsnotify.RemoveCallback(callback.Id) - glog.Println("remove callback") + glog.Print("remove callback") }) select {} diff --git a/.example/os/gfsnotify/gfsnotify_limit.go b/.example/os/gfsnotify/gfsnotify_limit.go index 4f71b8df1..33522de5c 100644 --- a/.example/os/gfsnotify/gfsnotify_limit.go +++ b/.example/os/gfsnotify/gfsnotify_limit.go @@ -10,7 +10,7 @@ func main() { path := "/Users/john/temp/log" for i := 0; i < 9999999; i++ { _, err := gfsnotify.Add(path, func(event *gfsnotify.Event) { - glog.Println(event) + glog.Print(event) }) if err != nil { glog.Fatal(err) diff --git a/.example/os/glog/glog_writer_greylog.go b/.example/os/glog/glog_writer_greylog.go index f965bde38..4f0824a47 100644 --- a/.example/os/glog/glog_writer_greylog.go +++ b/.example/os/glog/glog_writer_greylog.go @@ -26,5 +26,5 @@ package main // MaxChunkSizeLan : 1337, // }), // }) -// glog.Println("test log") +// glog.Print("test log") //} diff --git a/.example/os/glog/handler/glog_handler_greylog.go b/.example/os/glog/handler/glog_handler_greylog.go index 8682de336..295ea11f9 100644 --- a/.example/os/glog/handler/glog_handler_greylog.go +++ b/.example/os/glog/handler/glog_handler_greylog.go @@ -27,5 +27,5 @@ package main // g.Log().Debug("Debugging...") // g.Log().Warning("It is warning info") // g.Log().Error("Error occurs, please have a check") -// glog.Println("test log") +// glog.Print("test log") //} diff --git a/.example/os/gmlock/1.lock&unlock.go b/.example/os/gmlock/1.lock&unlock.go index 6e613bb6b..caaba0916 100644 --- a/.example/os/gmlock/1.lock&unlock.go +++ b/.example/os/gmlock/1.lock&unlock.go @@ -18,7 +18,7 @@ func main() { wg.Add(1) go func(i int) { gmlock.Lock(key) - glog.Println(i) + glog.Print(i) time.Sleep(time.Second) gmlock.Unlock(key) wg.Done() diff --git a/.example/os/gmlock/2.trylock.go b/.example/os/gmlock/2.trylock.go index 1a0decdf3..7fe2c421c 100644 --- a/.example/os/gmlock/2.trylock.go +++ b/.example/os/gmlock/2.trylock.go @@ -16,11 +16,11 @@ func main() { wg.Add(1) go func(i int) { if gmlock.TryLock(key) { - glog.Println(i) + glog.Print(i) time.Sleep(time.Second) gmlock.Unlock(key) } else { - glog.Println(false) + glog.Print(false) } wg.Done() }(i) diff --git a/.example/os/gmlock/3.lock_conflicts.go b/.example/os/gmlock/3.lock_conflicts.go index 69935d714..712080a4a 100644 --- a/.example/os/gmlock/3.lock_conflicts.go +++ b/.example/os/gmlock/3.lock_conflicts.go @@ -14,26 +14,26 @@ func main() { // 第一次锁带时间 gmlock.Lock(key) - glog.Println("lock1") + glog.Print("lock1") // 这个时候上一次的计时解锁已失效 gmlock.Unlock(key) - glog.Println("unlock1") + glog.Print("unlock1") fmt.Println() // 第二次锁,不带时间,且在执行过程中钱一个Lock的定时解锁生效 gmlock.Lock(key) - glog.Println("lock2") + glog.Print("lock2") go func() { // 正常情况下3秒后才能执行这句 gmlock.Lock(key) - glog.Println("lock by goroutine") + glog.Print("lock by goroutine") }() time.Sleep(3 * time.Second) // 这时再解锁 gmlock.Unlock(key) // 注意3秒之后才会执行这一句 - glog.Println("unlock2") + glog.Print("unlock2") select {} } diff --git a/.example/os/gmutex/gmutex_basic.go b/.example/os/gmutex/gmutex_basic.go index e82f9f81c..5ca0944fa 100644 --- a/.example/os/gmutex/gmutex_basic.go +++ b/.example/os/gmutex/gmutex_basic.go @@ -13,7 +13,7 @@ func main() { go func(n int) { mu.Lock() defer mu.Unlock() - glog.Println("Lock:", n) + glog.Print("Lock:", n) time.Sleep(time.Second) }(i) } @@ -21,7 +21,7 @@ func main() { go func(n int) { mu.RLock() defer mu.RUnlock() - glog.Println("RLock:", n) + glog.Print("RLock:", n) time.Sleep(time.Second) }(i) } diff --git a/.example/os/gmutex/gmutex_func.go b/.example/os/gmutex/gmutex_func.go index dead2b8f5..cc2515883 100644 --- a/.example/os/gmutex/gmutex_func.go +++ b/.example/os/gmutex/gmutex_func.go @@ -11,12 +11,12 @@ import ( func main() { mu := gmutex.New() go mu.LockFunc(func() { - glog.Println("lock func1") + glog.Print("lock func1") time.Sleep(1 * time.Second) }) time.Sleep(time.Millisecond) go mu.LockFunc(func() { - glog.Println("lock func2") + glog.Print("lock func2") }) time.Sleep(2 * time.Second) } diff --git a/.example/os/gtimer/gtimer3.go b/.example/os/gtimer/gtimer3.go index a46679028..aa726c704 100644 --- a/.example/os/gtimer/gtimer3.go +++ b/.example/os/gtimer/gtimer3.go @@ -10,7 +10,7 @@ import ( func main() { interval := time.Second gtimer.AddSingleton(interval, func() { - glog.Println("doing") + glog.Print("doing") time.Sleep(5 * time.Second) }) diff --git a/.example/os/gtimer/gtimer4.go b/.example/os/gtimer/gtimer4.go index acaa9b706..88dea15bf 100644 --- a/.example/os/gtimer/gtimer4.go +++ b/.example/os/gtimer/gtimer4.go @@ -10,10 +10,10 @@ import ( func main() { interval := time.Second gtimer.AddTimes(interval, 2, func() { - glog.Println("doing1") + glog.Print("doing1") }) gtimer.AddTimes(interval, 2, func() { - glog.Println("doing2") + glog.Print("doing2") }) select {} diff --git a/net/gsmtp/gsmtp.go b/net/gsmtp/gsmtp.go index 5a1aa1aa2..eeb06aa0b 100644 --- a/net/gsmtp/gsmtp.go +++ b/net/gsmtp/gsmtp.go @@ -8,7 +8,7 @@ // // Eg: // s := smtp.New("smtp.exmail.qq.com:25", "notify@a.com", "password") -// glog.Println(s.SendMail("notify@a.com", "ulric@b.com;rain@c.com", "subject", "body, red")) +// glog.Print(s.SendMail("notify@a.com", "ulric@b.com;rain@c.com", "subject", "body, red")) package gsmtp import ( diff --git a/os/gcron/gcron_z_example_1_test.go b/os/gcron/gcron_z_example_1_test.go index 1826b4010..eb99138e7 100644 --- a/os/gcron/gcron_z_example_1_test.go +++ b/os/gcron/gcron_z_example_1_test.go @@ -16,7 +16,7 @@ import ( func Example_cronAddSingleton() { gcron.AddSingleton(ctx, "* * * * * *", func(ctx context.Context) { - glog.Println(context.TODO(), "doing") + glog.Print(context.TODO(), "doing") time.Sleep(2 * time.Second) }) select {} diff --git a/os/glog/glog_api.go b/os/glog/glog_api.go index c5b8e22ec..cfb5a26b7 100644 --- a/os/glog/glog_api.go +++ b/os/glog/glog_api.go @@ -20,12 +20,6 @@ func Printf(ctx context.Context, format string, v ...interface{}) { logger.Printf(ctx, format, v...) } -// Println is alias of Print. -// See Print. -func Println(ctx context.Context, v ...interface{}) { - logger.Println(ctx, v...) -} - // Fatal prints the logging content with [FATA] header and newline, then exit the current process. func Fatal(ctx context.Context, v ...interface{}) { logger.Fatal(ctx, v...) diff --git a/os/glog/glog_logger.go b/os/glog/glog_logger.go index 2b273c10e..79be582b7 100644 --- a/os/glog/glog_logger.go +++ b/os/glog/glog_logger.go @@ -355,9 +355,9 @@ func (l *Logger) format(format string, value ...interface{}) string { // the optional parameter `skip` specify the skipped stack offset from the end point. func (l *Logger) PrintStack(ctx context.Context, skip ...int) { if s := l.GetStack(skip...); s != "" { - l.Println(ctx, "Stack:\n"+s) + l.Print(ctx, "Stack:\n"+s) } else { - l.Println(ctx) + l.Print(ctx) } } diff --git a/os/glog/glog_logger_api.go b/os/glog/glog_logger_api.go index d6ee98061..d485d6fc2 100644 --- a/os/glog/glog_logger_api.go +++ b/os/glog/glog_logger_api.go @@ -24,12 +24,6 @@ func (l *Logger) Printf(ctx context.Context, format string, v ...interface{}) { l.printStd(ctx, LEVEL_NONE, l.format(format, v...)) } -// Println is alias of Print. -// See Print. -func (l *Logger) Println(ctx context.Context, v ...interface{}) { - l.Print(ctx, v...) -} - // Fatal prints the logging content with [FATA] header and newline, then exit the current process. func (l *Logger) Fatal(ctx context.Context, v ...interface{}) { l.printErr(ctx, LEVEL_FATA, v...) diff --git a/os/glog/glog_z_unit_basic_test.go b/os/glog/glog_z_unit_basic_test.go index b3ec903df..393953847 100644 --- a/os/glog/glog_z_unit_basic_test.go +++ b/os/glog/glog_z_unit_basic_test.go @@ -23,10 +23,9 @@ func Test_Print(t *testing.T) { w := bytes.NewBuffer(nil) l := NewWithWriter(w) l.Print(ctx, 1, 2, 3) - l.Println(ctx, 1, 2, 3) l.Printf(ctx, "%d %d %d", 1, 2, 3) t.Assert(gstr.Count(w.String(), "["), 0) - t.Assert(gstr.Count(w.String(), "1 2 3"), 3) + t.Assert(gstr.Count(w.String(), "1 2 3"), 2) }) } diff --git a/os/gmutex/gmutex_unit_test.go b/os/gmutex/gmutex_unit_test.go index 36e6b714f..24f8a5235 100644 --- a/os/gmutex/gmutex_unit_test.go +++ b/os/gmutex/gmutex_unit_test.go @@ -249,7 +249,7 @@ func Test_Mutex_TryRLockFunc(t *testing.T) { go func() { mu.LockFunc(func() { array.Append(1) - glog.Println(context.TODO(), "lock1 done") + glog.Print(context.TODO(), "lock1 done") time.Sleep(2000 * time.Millisecond) }) }() diff --git a/os/gtimer/gtimer_z_unit_timer_test.go b/os/gtimer/gtimer_z_unit_timer_test.go index 222e143cd..a2df98054 100644 --- a/os/gtimer/gtimer_z_unit_timer_test.go +++ b/os/gtimer/gtimer_z_unit_timer_test.go @@ -248,15 +248,15 @@ func TestTimer_AddLeveledJob1(t *testing.T) { gtest.C(t, func(t *gtest.T) { timer := New() array := garray.New(true) - //glog.Println("start") + //glog.Print("start") timer.DelayAdd(ctx, 1000*time.Millisecond, 1000*time.Millisecond, func(ctx context.Context) { - //glog.Println("add") + //glog.Print("add") array.Append(1) }) time.Sleep(1500 * time.Millisecond) t.Assert(array.Len(), 0) time.Sleep(1300 * time.Millisecond) - //glog.Println("check") + //glog.Print("check") t.Assert(array.Len(), 1) }) }