Skip to content

Commit

Permalink
Interna; changes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxan98 committed Aug 13, 2021
1 parent 2b2038c commit f4b4d54
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/bombsimon/logrusr
module github.com/maxan98/logrusr

go 1.13

Expand Down
5 changes: 0 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ 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=
github.com/go-logr/logr v0.1.0 h1:M1Tv3VzNlEHg6uyACnRdtrploV2P7wZqH8BoQMtz0cg=
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
Expand All @@ -18,19 +17,15 @@ github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 h1:1/DFK4b7JH8DmkqhUk48onnSfrPzImPoVxuomtbT2nk=
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
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/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
55 changes: 52 additions & 3 deletions logrusr.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ import (
const (
logrusDiffToInfo = 4
)
const (
PanicLevel = iota - 4
FatalLevel
ErrorLevel
WarnLevel
InfoLevel
DebugLevel
TraceLevel
)

type logrusr struct {
name []string
Expand Down Expand Up @@ -105,10 +114,50 @@ func (l *logrusr) Info(msg string, keysAndValues ...interface{}) {
if !l.Enabled() {
return
}
switch l.level {
case InfoLevel:
l.level = int(logrus.InfoLevel)
l.logger.
WithFields(listToLogrusFields(l.defaultFormatter, keysAndValues...)).
Info(msg)
case WarnLevel:
l.level = int(logrus.WarnLevel)
l.logger.
WithFields(listToLogrusFields(l.defaultFormatter, keysAndValues...)).
Warn(msg)
case DebugLevel:
l.level = int(logrus.DebugLevel)
l.logger.
WithFields(listToLogrusFields(l.defaultFormatter, keysAndValues...)).
Debug(msg)
case TraceLevel:
l.level = int(logrus.TraceLevel)
l.logger.
WithFields(listToLogrusFields(l.defaultFormatter, keysAndValues...)).
Trace(msg)
case ErrorLevel:
l.level = int(logrus.ErrorLevel)
l.logger.
WithFields(listToLogrusFields(l.defaultFormatter, keysAndValues...)).
Error(msg)
case PanicLevel:
l.level = int(logrus.PanicLevel)
l.logger.
WithFields(listToLogrusFields(l.defaultFormatter, keysAndValues...)).
Panic(msg)
case FatalLevel:
l.level = int(logrus.FatalLevel)
l.logger.
WithFields(listToLogrusFields(l.defaultFormatter, keysAndValues...)).
Fatal(msg)
default:
l.level = int(logrus.InfoLevel)
l.logger.
WithFields(listToLogrusFields(l.defaultFormatter, keysAndValues...)).
Info(msg)
}


l.logger.
WithFields(listToLogrusFields(l.defaultFormatter, keysAndValues...)).
Info(msg)
}

// Error logs error messages. Since the log will be written with `Error` level
Expand Down

0 comments on commit f4b4d54

Please sign in to comment.