g2gorm

package
v0.0.9-rc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Reset       = logger.Reset
	Red         = logger.Red
	Green       = logger.Green
	Yellow      = logger.Yellow
	Blue        = logger.Blue
	Magenta     = logger.Magenta
	Cyan        = logger.Cyan
	White       = logger.White
	BlueBold    = logger.BlueBold
	MagentaBold = logger.MagentaBold
	RedBold     = logger.RedBold
	YellowBold  = logger.YellowBold
)

Colors

View Source
const (
	// Silent silent log level
	Silent = logger.Silent
	// Info info log level
	Info = logger.Info
	// Warn warn log level
	Warn = logger.Warn
	// Error error log level
	Error = logger.Error
)

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(logger *zap.Logger, conf *config.OrmLogConfig, optHooks ...Hook) logger.Interface

func NewLoggerInterface

func NewLoggerInterface(writer Writer, config logger.Config) logger.Interface

func ParserLevel

func ParserLevel(lev string) (level logger.LogLevel)

ParserLevel 从字符串中解析 gorm 的日志等级 默认值为 info

func Register

func Register(driver string, dialect DialectFunc) (err error)

Types

type ConfigOption

type ConfigOption func(c *gorm.Config)

func WithLogger

func WithLogger(l logger.Interface) ConfigOption

func WithLoggerV2

func WithLoggerV2(logger *zap.Logger, conf *config.OrmLogConfig, optHooks ...Hook) ConfigOption

func WithName

func WithName(strategy schema.Namer) ConfigOption

func WithSingularTable

func WithSingularTable() ConfigOption

type DBHelper

type DBHelper interface {
	WithContext(ctx context.Context) (db *gorm.DB)
}

func NewDBHelper

func NewDBHelper(conf *config.EngineConfig, opts ...ConfigOption) (helper DBHelper, err error)

type DialectFunc

type DialectFunc func(dsn string) gorm.Dialector

type Entry

type Entry interface {
	Context() (ctx context.Context)
	AppendField(field zap.Field) (err error)
	GetFields() (fields []zap.Field)
}

type Hook

type Hook interface {
	Fire(e Entry) (err error)
	Levels() (levels []logger.LogLevel)
}

type Hooks

type Hooks map[logger.LogLevel][]Hook

func (Hooks) Fire

func (c Hooks) Fire(level logger.LogLevel, e Entry)

type Writer

type Writer interface {
	Printf(ctx context.Context, level logger.LogLevel, format string, values ...interface{})
}

func NewWriter

func NewWriter(logger *zap.Logger, optHooks ...Hook) (w Writer)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL