Documentation
¶
Overview ¶
Example ¶
package main import ( "github.com/r-fujiyama/zapgormv2" "go.uber.org/zap" "gorm.io/gorm" ) func main() { zapLogger, _ := zap.NewProduction() logger := zapgormv2.New(zapLogger) logger.SetAsDefault() // optional: configure gorm to use this zapgorm.Logger for callbacks db, _ := gorm.Open(nil, &gorm.Config{Logger: logger}) // do stuff normally var _ = db // avoid "unused variable" warn }
Output:
Index ¶
- type Logger
- func (l Logger) Error(ctx context.Context, msg string, data ...interface{})
- func (l Logger) Info(ctx context.Context, msg string, data ...interface{})
- func (l Logger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
- func (l Logger) SetAsDefault()
- func (l Logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l Logger) Warn(ctx context.Context, msg string, data ...interface{})
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct { ZapLogger *zap.Logger LogLevel gormlogger.LogLevel SlowThreshold time.Duration IgnoreRecordNotFoundError bool }
Logger that implements gorm.logger.Interface
func (Logger) LogMode ¶
func (l Logger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
LogMode log mode.
Click to show internal directories.
Click to hide internal directories.