core

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 33 Imported by: 9

Documentation

Index

Constants

View Source
const (
	ModeDev  Mode = "dev"  //开发模式
	ModeTest Mode = "test" //测试模式
	ModeProd Mode = "prod" //生产模式

	Mysql  DBType = "mysql" //mysql数据库标识
	Mssql  DBType = "mssql"
	Pgsql  DBType = "pgsql"
	Sqlite DBType = "sqlite" //sqlite
)
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"
)

Colors

Variables

View Source
var (
	Cfg config.AppCfg

	Cache cache.ICache

	RedisLock *locker.Redis
	Started   = make(chan byte, 1)
	ToClose   = make(chan byte, 1)
)
View Source
var (
	// Discard logger will print any log to io.Discard
	Discard = New(log.New(io.Discard, "", log.LstdFlags), Config{})
	// Default Default logger
	Default = New(log.New(os.Stdout, "\r\n", log.LstdFlags), Config{
		SlowThreshold:             200 * time.Millisecond,
		LogLevel:                  gormLogger.Warn,
		IgnoreRecordNotFoundError: false,
		Colorful:                  true,
	})
	// Recorder logger records running SQL into a recorder instance
	Recorder = traceRecorder{Interface: Default, BeginAt: time.Now()}
)
View Source
var ErrRecordNotFound = errors.New("record not found")

ErrRecordNotFound record not found error

View Source
var Version = "V0.0.1"

Functions

func DB

func DB() *gorm.DB

获取默认的(master)db

func Db

func Db(name string) *gorm.DB

func Dbs

func Dbs() map[string]*gorm.DB

GetDb 获取所有map里的db数据

func FileWithLineNum added in v1.0.17

func FileWithLineNum() string

func GetEngine

func GetEngine() http.Handler

func GetGinEngine

func GetGinEngine() *gin.Engine

func GetGromLogCfg

func GetGromLogCfg(logMode logger.LogLevel, prefix string, slowThreshold int, singular, color, ignoreNotFound bool, logW io.Writer, dryRun bool) *gorm.Config

func Init

func Init()

func New added in v1.0.17

func New(writer Writer, config Config) gormLogger.Interface

New initialize logger

func Run

func Run()

func SetDb

func SetDb(key string, db *gorm.DB)

func SetEngine

func SetEngine(aEngine http.Handler)

Types

type Config added in v1.0.17

type Config struct {
	SlowThreshold             time.Duration
	Colorful                  bool
	IgnoreRecordNotFoundError bool
	ParameterizedQueries      bool
	LogLevel                  gormLogger.LogLevel
}

Config logger config

type DBType

type DBType string

func (DBType) String

func (e DBType) String() string

type IServer

type IServer interface {
	GetEngine() http.Handler
}

type LogLevel added in v1.0.17

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 Mode

type Mode string

func (Mode) String

func (e Mode) String() string

type Writer added in v1.0.17

type Writer interface {
	Printf(string, ...interface{})
}

Writer log writer interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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