Code Monkey home page Code Monkey logo

gormv2-logrus's People

Contributors

florianruen avatar thomas-tacquet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gormv2-logrus's Issues

logging not working

  • mod
    go 1.20
require (
	github.com/coreos/go-systemd/v22 v22.5.0
	github.com/gin-gonic/gin v1.9.1
	github.com/sirupsen/logrus v1.9.3
	github.com/thomas-tacquet/gormv2-logrus v1.2.2
	gopkg.in/natefinch/lumberjack.v2 v2.2.1
	gorm.io/driver/mysql v1.5.1
	gorm.io/gorm v1.25.1
)
  • code
gormLogger := gormv2logrus.NewGormlog(
		gormv2logrus.WithLogrus(l),
		gormv2logrus.WithGormOptions(
			gormv2logrus.GormOptions{
				SlowThreshold: slowThresholdDuration,
				LogLevel:      logger.Info,
				LogLatency:    true,
			},
		),
	)

gormr, err := gorm.Open(mysql.New(mysql.Config{
		Conn: db,
	}), &gorm.Config{
		Logger:         gormLogger,
		TranslateError: true,
		NamingStrategy: schema.NamingStrategy{
			SingularTable: true, // Use singular table names
		},
	})
  • in my log file I don't see gorm logging, I try gorm.Debug() no logging
  • when I use gorm logger logger.Default.LogMode(logger.Silent) it works fine, but output is console

Difficults to parse with LogStash due to Logrus

@thomas-tacquet
We are using LogStash to parse and store all our app logs, but due to the logs format there is some challenges :

  • Colors code are not removed by Logrus, especially if we setup Logrus as JSONFormatter or redirecting the logs to a file
  • The Duration and Rows parameters are duplicate (in string and as parameter), the string can't be parsed easily
  • There is a new line on every log, so LogStash handle two logs line instead of only one

For the Colorful Option, there are many options to add this in Logrus options (such as red for duration parameter, blue for rows parameters). We need to use this way to add Colorful option

Production ready?

Hi, is this package already production ready or still under heavy development?

Use options to customize logger

Hi @thomas-tacquet ,

I'm looking to use this library to use Logrus as Gorm logger, but I didn't find how to modify the options, because none of the functions allowing it do not seem to be exported

The operation does not look usual, is it an error not to have exported the option structure or the newGormLogOption function ?
Maybe a small piece of doc to, for example, change the value of the logLatency parameter ?

KIndly,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.