From d8667522d7566974e5c69ce52b0e9f9dabd7fd0e Mon Sep 17 00:00:00 2001 From: plastikfan Date: Fri, 26 Apr 2024 10:17:23 +0100 Subject: [PATCH] ref(rx): remove log (#37) --- .vscode/settings.json | 4 ++++ go.mod | 7 ++----- go.sum | 14 ++++--------- internal/log/fields.go | 21 ------------------- internal/log/log-defs.go | 43 -------------------------------------- internal/log/new-logger.go | 37 -------------------------------- log/logger.go | 12 ----------- 7 files changed, 10 insertions(+), 128 deletions(-) delete mode 100644 internal/log/fields.go delete mode 100644 internal/log/log-defs.go delete mode 100644 internal/log/new-logger.go delete mode 100644 log/logger.go diff --git a/.vscode/settings.json b/.vscode/settings.json index c263b25..481d918 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,12 +6,14 @@ "cSpell.words": [ "astrolib", "bodyclose", + "cmds", "coverpkg", "coverprofile", "cubiest", "deadcode", "depguard", "dogsled", + "dotenv", "dupl", "errcheck", "exportloopref", @@ -36,6 +38,7 @@ "mattn", "nakedret", "nolintlint", + "outdir", "pixa", "prealloc", "repotoken", @@ -50,6 +53,7 @@ "unconvert", "unparam", "varcheck", + "watchv", "watchvc", "watchvi" ] diff --git a/go.mod b/go.mod index da8fadd..dabc111 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,9 @@ module github.com/snivilised/astrolib go 1.21 require ( - github.com/natefinch/lumberjack v2.0.0+incompatible github.com/onsi/ginkgo/v2 v2.17.1 github.com/onsi/gomega v1.33.0 - github.com/samber/lo v1.39.0 github.com/snivilised/extendio v0.6.1 - go.uber.org/zap v1.27.0 ) require ( @@ -20,12 +17,12 @@ require ( github.com/kr/pretty v0.3.1 // indirect github.com/nicksnyder/go-i18n/v2 v2.3.0 // indirect github.com/pkg/errors v0.9.1 // indirect - go.uber.org/multierr v1.11.0 // indirect + github.com/samber/lo v1.39.0 // indirect + github.com/stretchr/testify v1.7.0 // indirect golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect golang.org/x/net v0.23.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.17.0 // indirect - gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 05a9113..463a131 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= -github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM= -github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk= github.com/nicksnyder/go-i18n/v2 v2.3.0 h1:2NPsCsNFCVd7i+Su0xYsBrIhS3bE2XMv5gNTft2O+PQ= github.com/nicksnyder/go-i18n/v2 v2.3.0/go.mod h1:nxYSZE9M0bf3Y70gPQjN9ha7XNHX7gMc814+6wVyEI4= github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8= @@ -46,14 +44,12 @@ github.com/snivilised/lorax v0.4.4 h1:fxuuew+88yUC9JkTq2iQhGx8tvECBzj2ugjssWlTI6 github.com/snivilised/lorax v0.4.4/go.mod h1:82r6nAoXWo1sdLXpj5RxYbAmiomu+xYVIXPn+cgG7I4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= -go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= go.uber.org/zap/exp v0.2.0 h1:FtGenNNeCATRB3CmB/yEUnjEFeJWpB/pMcy7e2bKPYs= go.uber.org/zap/exp v0.2.0/go.mod h1:t0gqAIdh1MfKv9EwN/dLwfZnJxe9ITAZN78HEWPFWDQ= golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= @@ -71,8 +67,6 @@ google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHh gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= -gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/log/fields.go b/internal/log/fields.go deleted file mode 100644 index 0658431..0000000 --- a/internal/log/fields.go +++ /dev/null @@ -1,21 +0,0 @@ -package log - -import ( - "go.uber.org/zap" -) - -func String(key, val string) Field { - return zap.String(key, val) -} - -func Uint(key string, val uint) Field { - return zap.Uint(key, val) -} - -func Int(key string, val int) Field { - return zap.Int(key, val) -} - -func Float64(key string, val float64) Field { - return zap.Float64(key, val) -} diff --git a/internal/log/log-defs.go b/internal/log/log-defs.go deleted file mode 100644 index f13629b..0000000 --- a/internal/log/log-defs.go +++ /dev/null @@ -1,43 +0,0 @@ -package log - -import ( - "github.com/snivilised/extendio/xfs/utils" - "go.uber.org/zap" - "go.uber.org/zap/zapcore" -) - -type Field = zap.Field -type Level = zapcore.Level - -const ( - DebugLevel = zapcore.DebugLevel - InfoLevel = zapcore.InfoLevel - WarnLevel = zapcore.WarnLevel - ErrorLevel = zapcore.ErrorLevel -) - -type Logger interface { - Debug(msg string, fields ...Field) - Info(msg string, fields ...Field) - Warn(msg string, fields ...Field) - Error(msg string, fields ...Field) - Sync() error -} - -type Ref utils.RoProp[Logger] - -type Rotation struct { - Filename string - MaxSizeInMb int - MaxNoOfBackups int - MaxAgeInDays int -} - -type LoggerInfo struct { - Rotation - - Enabled bool - Path string - TimeStampFormat string - Level Level -} diff --git a/internal/log/new-logger.go b/internal/log/new-logger.go deleted file mode 100644 index ce604d9..0000000 --- a/internal/log/new-logger.go +++ /dev/null @@ -1,37 +0,0 @@ -package log - -import ( - "github.com/natefinch/lumberjack" - "github.com/samber/lo" - "github.com/snivilised/extendio/xfs/utils" - "go.uber.org/zap" - "go.uber.org/zap/zapcore" - - "github.com/snivilised/extendio/i18n" -) - -func NewLogger(info *LoggerInfo) Ref { - return utils.NewRoProp(lo.TernaryF(info.Enabled, - func() Logger { - if info.Path == "" { - panic(i18n.NewInvalidConfigEntryError(info.Path, "-")) - } - ws := zapcore.AddSync(&lumberjack.Logger{ - Filename: info.Path, - MaxSize: info.Rotation.MaxSizeInMb, - MaxBackups: info.Rotation.MaxNoOfBackups, - MaxAge: info.Rotation.MaxAgeInDays, - }) - config := zap.NewProductionEncoderConfig() - config.EncodeTime = zapcore.TimeEncoderOfLayout(info.TimeStampFormat) - core := zapcore.NewCore( - zapcore.NewJSONEncoder(config), - ws, - info.Level, - ) - return zap.New(core) - }, func() Logger { - return zap.NewNop() - }), - ) -} diff --git a/log/logger.go b/log/logger.go deleted file mode 100644 index 32d1e3c..0000000 --- a/log/logger.go +++ /dev/null @@ -1,12 +0,0 @@ -package log - -import ( - "github.com/snivilised/astrolib/internal/log" -) - -type Logger interface { - Debug(msg string, fields ...log.Field) - Info(msg string, fields ...log.Field) - Warn(msg string, fields ...log.Field) - Error(msg string, fields ...log.Field) -}