From cd60a4aca7402dcd989da12a93fe147109bb44ac Mon Sep 17 00:00:00 2001 From: houseme Date: Mon, 15 Nov 2021 20:31:16 +0800 Subject: [PATCH] [feature] improve code glog --- os/glog/glog_logger.go | 17 ++++++++--------- os/glog/glog_logger_config.go | 6 +++--- os/glog/glog_logger_level.go | 3 ++- os/glog/glog_logger_rotate.go | 3 ++- os/glog/glog_z_example_test.go | 1 + os/glog/glog_z_unit_basic_test.go | 3 ++- os/glog/glog_z_unit_chaining_test.go | 5 +++-- os/glog/glog_z_unit_concurrent_test.go | 5 +++-- os/glog/glog_z_unit_config_test.go | 3 ++- os/glog/glog_z_unit_ctx_test.go | 3 ++- os/glog/glog_z_unit_handler_test.go | 3 ++- os/glog/glog_z_unit_level_test.go | 3 ++- os/glog/glog_z_unit_rotate_test.go | 5 +++-- 13 files changed, 35 insertions(+), 25 deletions(-) diff --git a/os/glog/glog_logger.go b/os/glog/glog_logger.go index bdd873976..178c5828b 100644 --- a/os/glog/glog_logger.go +++ b/os/glog/glog_logger.go @@ -10,25 +10,24 @@ import ( "bytes" "context" "fmt" - "github.com/fatih/color" - "github.com/gogf/gf/v2/container/gtype" - "github.com/gogf/gf/v2/internal/intlog" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/os/gfpool" - "github.com/gogf/gf/v2/os/gmlock" - "github.com/gogf/gf/v2/os/gtimer" - "go.opentelemetry.io/otel/trace" "io" "os" "strings" "time" + "github.com/fatih/color" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/debug/gdebug" - + "github.com/gogf/gf/v2/internal/intlog" + "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gfpool" + "github.com/gogf/gf/v2/os/gmlock" "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/os/gtimer" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/util/gconv" + "go.opentelemetry.io/otel/trace" ) // Logger is the struct for logging management. diff --git a/os/glog/glog_logger_config.go b/os/glog/glog_logger_config.go index c33ac786e..20c36e699 100644 --- a/os/glog/glog_logger_config.go +++ b/os/glog/glog_logger_config.go @@ -8,14 +8,14 @@ package glog import ( "context" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/os/gctx" "io" "strings" "time" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" + "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gutil" @@ -255,7 +255,7 @@ func (l *Logger) SetHandlers(handlers ...Handler) { l.config.Handlers = handlers } -//SetWriterColorEnable sets the file logging with color +// SetWriterColorEnable sets the file logging with color func (l *Logger) SetWriterColorEnable(enabled bool) { l.config.WriterColorEnable = enabled } diff --git a/os/glog/glog_logger_level.go b/os/glog/glog_logger_level.go index 3f20e65d4..e1fe6b6a3 100644 --- a/os/glog/glog_logger_level.go +++ b/os/glog/glog_logger_level.go @@ -7,9 +7,10 @@ package glog import ( + "strings" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" - "strings" ) // Note that the LEVEL_PANI and LEVEL_FATA levels are not used for logging output, diff --git a/os/glog/glog_logger_rotate.go b/os/glog/glog_logger_rotate.go index 19470606b..6e7ca96de 100644 --- a/os/glog/glog_logger_rotate.go +++ b/os/glog/glog_logger_rotate.go @@ -9,6 +9,8 @@ package glog import ( "context" "fmt" + "time" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/encoding/gcompress" "github.com/gogf/gf/v2/internal/intlog" @@ -17,7 +19,6 @@ import ( "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtimer" "github.com/gogf/gf/v2/text/gregex" - "time" ) const ( diff --git a/os/glog/glog_z_example_test.go b/os/glog/glog_z_example_test.go index 3d8467b7d..e31c321c1 100644 --- a/os/glog/glog_z_example_test.go +++ b/os/glog/glog_z_example_test.go @@ -8,6 +8,7 @@ package glog_test import ( "context" + "github.com/gogf/gf/v2/frame/g" ) diff --git a/os/glog/glog_z_unit_basic_test.go b/os/glog/glog_z_unit_basic_test.go index 393953847..30ef4a4b7 100644 --- a/os/glog/glog_z_unit_basic_test.go +++ b/os/glog/glog_z_unit_basic_test.go @@ -9,9 +9,10 @@ package glog import ( "bytes" "context" + "testing" + "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" - "testing" ) var ( diff --git a/os/glog/glog_z_unit_chaining_test.go b/os/glog/glog_z_unit_chaining_test.go index 846ce62ca..f0f6989e5 100644 --- a/os/glog/glog_z_unit_chaining_test.go +++ b/os/glog/glog_z_unit_chaining_test.go @@ -9,12 +9,13 @@ package glog import ( "bytes" "fmt" + "testing" + "time" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" - "testing" - "time" ) func Test_To(t *testing.T) { diff --git a/os/glog/glog_z_unit_concurrent_test.go b/os/glog/glog_z_unit_concurrent_test.go index 43f036f68..a0d230dc1 100644 --- a/os/glog/glog_z_unit_concurrent_test.go +++ b/os/glog/glog_z_unit_concurrent_test.go @@ -7,13 +7,14 @@ package glog_test import ( + "sync" + "testing" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" - "sync" - "testing" ) func Test_Concurrent(t *testing.T) { diff --git a/os/glog/glog_z_unit_config_test.go b/os/glog/glog_z_unit_config_test.go index 43b2e1825..6b33466d9 100644 --- a/os/glog/glog_z_unit_config_test.go +++ b/os/glog/glog_z_unit_config_test.go @@ -8,9 +8,10 @@ package glog import ( "bytes" - "github.com/gogf/gf/v2/test/gtest" "strings" "testing" + + "github.com/gogf/gf/v2/test/gtest" ) func Test_SetConfigWithMap(t *testing.T) { diff --git a/os/glog/glog_z_unit_ctx_test.go b/os/glog/glog_z_unit_ctx_test.go index 028ed0a5b..a760cd331 100644 --- a/os/glog/glog_z_unit_ctx_test.go +++ b/os/glog/glog_z_unit_ctx_test.go @@ -9,12 +9,13 @@ package glog_test import ( "bytes" "context" + "testing" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" - "testing" ) func Test_Ctx(t *testing.T) { diff --git a/os/glog/glog_z_unit_handler_test.go b/os/glog/glog_z_unit_handler_test.go index 587614f92..aeca8983e 100644 --- a/os/glog/glog_z_unit_handler_test.go +++ b/os/glog/glog_z_unit_handler_test.go @@ -9,11 +9,12 @@ package glog_test import ( "bytes" "context" + "testing" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" - "testing" ) var arrayForHandlerTest1 = garray.NewStrArray() diff --git a/os/glog/glog_z_unit_level_test.go b/os/glog/glog_z_unit_level_test.go index cb49574a0..c5c9b68aa 100644 --- a/os/glog/glog_z_unit_level_test.go +++ b/os/glog/glog_z_unit_level_test.go @@ -8,9 +8,10 @@ package glog import ( "bytes" + "testing" + "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" - "testing" ) func Test_LevelPrefix(t *testing.T) { diff --git a/os/glog/glog_z_unit_rotate_test.go b/os/glog/glog_z_unit_rotate_test.go index 7ec5fe090..36da85b1d 100644 --- a/os/glog/glog_z_unit_rotate_test.go +++ b/os/glog/glog_z_unit_rotate_test.go @@ -9,14 +9,15 @@ package glog_test import ( "context" "fmt" + "testing" + "time" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" - "testing" - "time" ) var (