gormi

package
v0.0.0-...-1f4ee57 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultV2 = New2(logi.Default.Logger, &logger.Config{
		SlowThreshold: 100 * time.Millisecond,
		LogLevel:      logger.Warn,
		Colorful:      true,
	})
)

Functions

func DelByAuthDB

func DelByAuthDB(db *gorm.DB, tableName string, id, userId uint64) error

func DelDB

func DelDB(db *gorm.DB, tableName string, id uint64) error

func ExistsByAuthDB

func ExistsByAuthDB(db *gorm.DB, tableName string, id, userId uint64) (bool, error)

func ExistsDB

func ExistsDB(db *gorm.DB, tableName string, id uint64) (bool, error)

func GetDB

func GetDB(db *gorm.DB, log *log.Logger, conf *logger.Config) *gorm.DB

func LogFormatter

func LogFormatter(values ...interface{}) (messages []interface{})

func New2

func New2(loger *zap.Logger, conf *logger.Config) logger.Interface

func Page

func Page(pageNo, pageSize int) clause.Limit

func SetTranceId

func SetTranceId(traceId string) context.Context

Types

type Config

type Config struct {
	SlowThreshold time.Duration
	Colorful      bool
	LogLevel      zapcore.Level
}

type GORMConfig

type GORMConfig struct {
	Config gorm.Config
	Logger logger.Config
}

func (*GORMConfig) Init

func (c *GORMConfig) Init()

type SQLLogger

type SQLLogger struct {
	*zap.Logger
	*logger.Config
}

func (*SQLLogger) Error

func (l *SQLLogger) Error(ctx context.Context, msg string, data ...interface{})

Error print error messages

func (*SQLLogger) Info

func (l *SQLLogger) Info(ctx context.Context, msg string, data ...interface{})

Info print info

func (*SQLLogger) LogMode

func (l *SQLLogger) LogMode(level logger.LogLevel) logger.Interface

LogMode log mode

func (*SQLLogger) Trace

func (l *SQLLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

Trace print sql message 只有这里的context不是background,看了代码,也没用

func (*SQLLogger) Warn

func (l *SQLLogger) Warn(ctx context.Context, msg string, data ...interface{})

Warn print warn messages

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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