Skip to content

Commit

Permalink
fix: Satisfies
Browse files Browse the repository at this point in the history
  • Loading branch information
pieceowater committed Oct 7, 2024
1 parent 7e94612 commit adbebc0
Show file tree
Hide file tree
Showing 4 changed files with 221 additions and 116 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/joho/godotenv v1.5.1
github.com/rabbitmq/amqp091-go v1.10.0
github.com/rs/zerolog v1.33.0
github.com/sirupsen/logrus v1.9.3
gorm.io/driver/clickhouse v0.6.1
gorm.io/driver/postgres v1.5.9
gorm.io/gorm v1.25.12
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down Expand Up @@ -138,6 +140,7 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
33 changes: 33 additions & 0 deletions internal/tools/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package tools
import (
"encoding/json"
"github.com/rs/zerolog/log"
"github.com/sirupsen/logrus"
"os"
)

func (inst *Tools) LogAction(action string, data any) {
Expand All @@ -14,3 +16,34 @@ func (inst *Tools) LogAction(action string, data any) {

log.Info().Str("action", action).Bytes("data", body).Msg("Action logged")
}

var Logger *logrus.Logger

func init() {
Logger = logrus.New()

// Set the output to stdout
Logger.SetOutput(os.Stdout)

// Set the log level (can be adjusted based on the environment)
Logger.SetLevel(logrus.InfoLevel)

// Optionally, set a formatter (e.g., JSON or Text)
Logger.SetFormatter(&logrus.TextFormatter{
FullTimestamp: true,
})
}

// LogError logs an error message with additional context
func LogError(err error, context string) {
Logger.WithFields(logrus.Fields{
"context": context,
}).Error(err)
}

// LogPanic logs a panic message and recovers from it
func LogPanic(err interface{}) {
Logger.WithFields(logrus.Fields{
"panic": err,
}).Panic("A panic occurred")
}
Loading

0 comments on commit adbebc0

Please sign in to comment.