Documentation ¶
Index ¶
- Constants
- Variables
- func DB() *gorm.DB
- func Db(name string) *gorm.DB
- func Dbs() map[string]*gorm.DB
- func FileWithLineNum() string
- func GetEngine() http.Handler
- func GetGinEngine() *gin.Engine
- func GetGromLogCfg(logMode logger.LogLevel, prefix string, slowThreshold int, ...) *gorm.Config
- func Init()
- func New(writer Writer, config Config) gormLogger.Interface
- func Run()
- func SetDb(key string, db *gorm.DB)
- func SetEngine(aEngine http.Handler)
- type Config
- type DBType
- type IServer
- type LogLevel
- type Mode
- type Writer
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 FileWithLineNum ¶ added in v1.0.17
func FileWithLineNum() string
func GetGinEngine ¶
func GetGromLogCfg ¶
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
Source Files ¶
Click to show internal directories.
Click to hide internal directories.