-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00e0986
commit 36b24cb
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
## 1.0.0 | ||
### Added | ||
- Gormlog library | ||
- Example in readme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,30 @@ | ||
# gormv2-logrus | ||
Easily connect Gorm V2 and logrus with customizable options | ||
|
||
Usage example : | ||
|
||
```go | ||
package test | ||
|
||
import ( | ||
gormv2logrus "github.com/thomas-tacquet/gormv2-logrus" | ||
"gorm.io/gorm" | ||
"gorm.io/gorm/logger" | ||
) | ||
|
||
func myFunctionToConnectOnMyDB(e *logrus.Entry) { | ||
gormLogger := gormv2logrus.NewGormlog(gormv2logrus.WithLogrusEntry(e)) | ||
gormLogger.LogMode(logger.Error) | ||
|
||
gormConfig := &gorm.Config{ | ||
Logger: gormLogger, | ||
CreateBatchSize: 1500, | ||
SkipDefaultTransaction: true, | ||
} | ||
|
||
db, err := gorm.Open( | ||
"CONNEXION STRING", | ||
gormConfig, | ||
) | ||
} | ||
``` |