duty

package
v1.0.774 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Reset       = "\033[0m"
	Red         = "\033[31m"
	Green       = "\033[32m"
	Yellow      = "\033[33m"
	Blue        = "\033[34m"
	Magenta     = "\033[35m"
	Cyan        = "\033[36m"
	White       = "\033[37m"
	BlueBold    = "\033[34;1m"
	MagentaBold = "\033[35;1m"
	RedBold     = "\033[31;1m"
	YellowBold  = "\033[33;1m"
)

Variables

This section is empty.

Functions

func FromCommonsLevel added in v1.0.564

func FromCommonsLevel(l commons.Logger, level any) logger.LogLevel

func NewSqlLogger added in v1.0.564

func NewSqlLogger(logger *commons.SlogLogger) logger.Interface

Types

type Config added in v1.0.564

type Config struct {
	// SlowThreshold in nanoseconds
	SlowThreshold             int64
	Colorful                  bool
	IgnoreRecordNotFoundError bool
	LogLevel                  int
}

type LogLevel added in v1.0.564

type LogLevel int

LogLevel log level

const (
	// Silent silent log level
	Silent LogLevel = iota + 1
	// Error error log level
	Error
	// Warn warn log level
	Warn
	// Info info log level
	Info
)

type Logger added in v1.0.564

type Logger interface {
	LogMode(LogLevel) logger.Interface
	Info(context.Context, string, ...interface{})
	Warn(context.Context, string, ...interface{})
	Error(context.Context, string, ...interface{})
	Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)
}

type SqlLogger added in v1.0.564

type SqlLogger struct {
	Config
	commons.Logger
	// contains filtered or unexported fields
}

func (SqlLogger) Error added in v1.0.564

func (s SqlLogger) Error(ctx context.Context, format string, args ...interface{})

func (SqlLogger) Info added in v1.0.564

func (s SqlLogger) Info(ctx context.Context, format string, args ...interface{})

func (*SqlLogger) LogMode added in v1.0.564

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

func (*SqlLogger) ParamsFilter added in v1.0.564

func (l *SqlLogger) ParamsFilter(ctx context.Context, sql string, params ...interface{}) (string, []interface{})

ParamsFilter filter params

func (*SqlLogger) Trace added in v1.0.564

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

Trace print sql message

func (SqlLogger) Warn added in v1.0.564

func (s SqlLogger) Warn(ctx context.Context, format string, args ...interface{})

func (*SqlLogger) WithLogLevel added in v1.0.564

func (l *SqlLogger) WithLogLevel(level any) *SqlLogger

func (*SqlLogger) WithLogger added in v1.0.567

func (l *SqlLogger) WithLogger(name string, level any) *SqlLogger

Jump to

Keyboard shortcuts

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