diff --git a/go.mod b/go.mod index 313b34a..1edb8ab 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,7 @@ require ( git.bit5.ru/backend/dbr v1.2.0 git.bit5.ru/backend/errors v1.0.0 git.bit5.ru/backend/mysql v1.0.0 - git.bit5.ru/backend/res_tracker v1.1.1 github.com/go-logr/logr v1.2.3 - github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-logr/stdr v1.2.2 github.com/stretchr/testify v1.8.1 ) diff --git a/go.sum b/go.sum index c974866..08f8bfd 100644 --- a/go.sum +++ b/go.sum @@ -1,15 +1,9 @@ -git.bit5.ru/backend/colog v1.0.0 h1:FLykTQuRfnhWYQ+dZhoaOfkxjHNEfWp4AwP/KD+ob+M= -git.bit5.ru/backend/colog v1.0.0/go.mod h1:fiOrMQ7SPBD5Pn/Tb7rG1phsDQbZaA7S0vtdnlM6BK4= -git.bit5.ru/backend/dbr v1.0.0 h1:sDxNkjYuyVovFP+Tx/TE0a17zLY7Sfn6qKEIb6ZIJYM= -git.bit5.ru/backend/dbr v1.0.0/go.mod h1:NP1BTND68eshI4Mv6SmSMh7COuy0fTiiHnUCT7ufB+o= git.bit5.ru/backend/dbr v1.2.0 h1:SQndOC9KW/jPGRSFSPYRqmMd+EHEyZHWDO9B+imEEzU= git.bit5.ru/backend/dbr v1.2.0/go.mod h1:3iCyHEkyj2M+lx3fSlv3lC1r5cLZZz+6QLVCml7ZAy8= git.bit5.ru/backend/errors v1.0.0 h1:WWJ0sly44q1HQjN01X75ZAGKZwwY5Ml+XVDXMjCkToA= git.bit5.ru/backend/errors v1.0.0/go.mod h1:75faRwsnpM0Se00/Bh7fysWQXV8oMjNJFQ6f7+r9k3Y= git.bit5.ru/backend/mysql v1.0.0 h1:NKxTr5p7vti/qrig6zZtWaDeiLRRgPkMB0Nz7AGGlIY= git.bit5.ru/backend/mysql v1.0.0/go.mod h1:iK3dzIpv9YAGN8Fy6zi1XGUX8R5nl9XQ9NJbwYM7y0w= -git.bit5.ru/backend/res_tracker v1.1.1 h1:MVGJe8G4TFMoSZdV55BxEmEJr10gjLl13Izw6J+02n4= -git.bit5.ru/backend/res_tracker v1.1.1/go.mod h1:ffjnItxqkGc6rxOK9XgrQDirGhmIBwoqibmyLJ4TZtQ= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -18,9 +12,6 @@ github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA= -github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -30,14 +21,6 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/logger.go b/logger.go index dfa24d9..ce17f0c 100644 --- a/logger.go +++ b/logger.go @@ -14,13 +14,13 @@ type EventReceiver struct { // Event receives a simple notification when various events occur func (n *EventReceiver) Event(eventName string) { - n.logger.WithCallDepth(5).V(1).Info(eventName) + n.logger.WithCallDepth(3).V(0).Info(eventName) } // EventKv receives a notification when various events occur along with // optional key/value data func (n *EventReceiver) EventKv(eventName string, kvs map[string]string) { - n.logger.WithCallDepth(5).V(1).Info(eventName) + n.logger.WithCallDepth(3).V(0).Info(eventName) } // EventErr receives a notification of an error if one occurs @@ -38,21 +38,21 @@ func (n *EventReceiver) Timing(eventName string, nanoseconds int64) { // TimingKv receives the time an event took to happen along with optional key/value data func (n *EventReceiver) TimingKv(eventName string, nanoseconds int64, kvs map[string]string) { - sql := kvs["sql"] - sp := strings.Index(sql, " ") - if sp != -1 { - query := sql[:sp] - if n.s.LogLevel > 1 { - n.logger.WithCallDepth(6).V(1).Info(sql) - } else { - if len(sql) > 50 { - sql = sql[:50] + "..." - } - if query == "SELECT" && n.s.LogLevel > 0 { - n.logger.WithCallDepth(6).V(1).Info(sql) - } else { - n.logger.WithCallDepth(6).V(1).Info(sql) - } - } - } + sql := kvs["sql"] + sp := strings.Index(sql, " ") + if sp != -1 { + query := sql[:sp] + if n.s.LogLevel > 1 { + n.logger.WithCallDepth(3).V(0).Info(sql) + } else { + if len(sql) > 50 { + sql = sql[:50] + "..." + } + if query == "SELECT" && n.s.LogLevel > 0 { + n.logger.WithCallDepth(3).V(0).Info(sql) + } else { + n.logger.WithCallDepth(3).V(0).Info(sql) + } + } + } }