Skip to content

erhanakp/sugaredgorm

Repository files navigation

Version Go Documentation Go Report Card Go Build Status GolangCI-Lint Status codecov Powered by Rake

Sugared Gorm

Custom GORM logger implementation enhanced with SugarLogger for improved log level management and standardized log outputs.

Features

  • Integrate GORM database logging with the powerful SugarLogger library.
  • Easily manage log levels and control verbosity for debugging.
  • Standardized and customizable log outputs for better readability and analysis.

Installation

Now you can add this package via;

go get -u github.com/erhanakp/sugaredgorm

Install godoc for documentation;

go install golang.org/x/tools/cmd/godoc@latest

Usage:

zap := zap.NewExample()

gormLoggerValue := sugaredgorm.New(zap.Sugar(), sugaredgorm.Config{
	SlowThreshold:             200 * time.Millisecond,
	Colorful:                  true,
	IgnoreRecordNotFoundError: true,
	ParameterizedQueries:      true,
})

_, err := gorm.Open(postgres.New(postgres.Config{
	DSN: "host=localhost",
}), &gorm.Config{
	Logger: gormLoggerValue,
})

Rake Tasks

rake -T

rake bump[revision]     # bump version, default is: patch
rake doc[port]          # run doc server
rake lint               # run golangci-lint
rake publish[revision]  # publish new version of the library, default is: patch
rake test               # run tests

Contributor(s)


Contribute

All PR’s are welcome!

  1. fork (https://github.com/erhanakp/sugaredgorm/fork)
  2. Create your branch (git checkout -b my-feature)
  3. commit yours (git commit -am 'add some functionality')
  4. push your branch (git push origin my-feature)
  5. Than create a new Pull Request!

This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.


License

This project is licensed under MIT