Documentation
ΒΆ
Overview ΒΆ
message from the author:
+--------------------------------------------------------------+ | * * * ββββββββββββββββββββ Hello ββββββββββββββββββββββββββ| +--------------------------------------------------------------+ | | | ++ ______________________________________ | | ++++ / \ | | ++++ | | | | ++++++++++ | Feel free to contribute to this | | | +++ | | project or contact me on | | | ++ | | manfred.life if you like this | | | + -== ==| | project! | | | ( <*> <*> | | | | | | /| :) | | | | _) / | | | | | +++ / \______________________________________/ | | \ =+ / | | \ + | | |\++++++ | | | ++++ ||// | | ___| |___ _||/__ __| | / --- \ \| ||| __ _ ___ __ __/ /| |/ | | \ \ / / ' \/ _ \/ // / / | || | | | | | /_/_/_/\___/\_,_/_/ | +--------------------------------------------------------------+
Example ΒΆ
package main import ( "go.uber.org/zap" "gorm.io/gorm" "github.com/68696c6c/zapgorm2" ) func main() { logger := zapgorm2.New(zap.L()) 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 ContextFn
- type Logger
- func (l Logger) Error(ctx context.Context, str string, args ...any)
- func (l Logger) Info(ctx context.Context, str string, args ...any)
- 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, str string, args ...any)
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 SkipCallerLookup bool IgnoreRecordNotFoundError bool Context ContextFn }
func (Logger) LogMode ΒΆ
func (l Logger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
func (Logger) SetAsDefault ΒΆ
func (l Logger) SetAsDefault()
Click to show internal directories.
Click to hide internal directories.