Documentation ¶
Index ¶
- Constants
- Variables
- func AddGetDataToUrl(urlString string, data url.Values) string
- func CloseDB() error
- func ClosePGDB() error
- func CreateBizDLTag(tagName string) string
- func DBPoolLogQuery(trace *TraceContext, sqlDb *sql.DB, query string, args ...interface{}) (*sql.Rows, error)
- func Destroy()
- func Encode(data string) (string, error)
- func GetBoolConf(key string) bool
- func GetConf(key string) interface{}
- func GetConfEnv() string
- func GetConfFilePath(fileName string) string
- func GetConfPath(fileName string) string
- func GetDBPool(name string) (*sql.DB, error)
- func GetDurationConf(key string) time.Duration
- func GetFloat64Conf(key string) float64
- func GetGormPool(name string) (*gorm.DB, error)
- func GetIntConf(key string) int
- func GetLocalIPs() (ips []net.IP)
- func GetMd5Hash(text string) string
- func GetPGDBPool(name string) (*sql.DB, error)
- func GetPGGormPool(name string) (*gorm.DB, error)
- func GetStringConf(key string) string
- func GetStringMapConf(key string) map[string]interface{}
- func GetStringMapStringConf(key string) map[string]string
- func GetStringSliceConf(key string) []string
- func GetTimeConf(key string) time.Time
- func GetTraceId() (traceId string)
- func HttpGET(trace *TraceContext, urlString string, urlParams url.Values, msTimeout int, ...) (*http.Response, []byte, error)
- func HttpJSON(trace *TraceContext, urlString string, jsonContent string, msTimeout int, ...) (*http.Response, []byte, error)
- func HttpPOST(trace *TraceContext, urlString string, urlParams url.Values, msTimeout int, ...) (*http.Response, []byte, error)
- func InArrayString(s string, arr []string) bool
- func Init(configPath string) error
- func InitBaseConf(path string) error
- func InitDBPool(path string) error
- func InitModule(configPath string, modules []string) error
- func InitPGDBPool(path string) error
- func InitRedisConf(path string) error
- func InitViperConf() error
- func IsSetConf(key string) bool
- func NewSpanId() string
- func PGDBPoolLogQuery(trace *TraceContext, sqlDb *sql.DB, query string, args ...interface{}) (*sql.Rows, error)
- func ParseConfPath(config string) error
- func ParseConfig(path string, conf interface{}) error
- func ParseLocalConfig(fileName string, st interface{}) error
- func ParseServerAddr(serverAddr string) (host, port string)
- func RedisConfDo(trace *TraceContext, name string, commandName string, args ...interface{}) (interface{}, error)
- func RedisConnFactory(name string) (redis.Conn, error)
- func RedisLogDo(trace *TraceContext, c redis.Conn, commandName string, args ...interface{}) (interface{}, error)
- func SetGinTraceContext(c *gin.Context, trace *TraceContext) error
- func SetTraceContext(ctx context.Context, trace *TraceContext) context.Context
- func Substr(str string, start int64, end int64) string
- type BaseConf
- type LogConfConsoleWriter
- type LogConfFileWriter
- type LogConfig
- type Logger
- func (l *Logger) Close()
- func (l *Logger) TagDebug(trace *TraceContext, dltag string, m map[string]interface{})
- func (l *Logger) TagError(trace *TraceContext, dltag string, m map[string]interface{})
- func (l *Logger) TagInfo(trace *TraceContext, dltag string, m map[string]interface{})
- func (l *Logger) TagTrace(trace *TraceContext, dltag string, m map[string]interface{})
- func (l *Logger) TagWarn(trace *TraceContext, dltag string, m map[string]interface{})
- type MySQLConf
- type MysqlGormLogger
- func (mgl *MysqlGormLogger) Error(ctx context.Context, message string, values ...interface{})
- func (mgl *MysqlGormLogger) Info(ctx context.Context, message string, values ...interface{})
- func (mgl *MysqlGormLogger) LogMode(logLevel logger.LogLevel) logger.Interface
- func (mgl *MysqlGormLogger) Trace(ctx context.Context, begin time.Time, ...)
- func (mgl *MysqlGormLogger) Warn(ctx context.Context, message string, values ...interface{})
- type MysqlMapConf
- type PGSqlConf
- type PGSqlGormLogger
- func (mgl *PGSqlGormLogger) Error(ctx context.Context, message string, values ...interface{})
- func (mgl *PGSqlGormLogger) Info(ctx context.Context, message string, values ...interface{})
- func (mgl *PGSqlGormLogger) LogMode(logLevel logger.LogLevel) logger.Interface
- func (mgl *PGSqlGormLogger) Trace(ctx context.Context, begin time.Time, ...)
- func (mgl *PGSqlGormLogger) Warn(ctx context.Context, message string, values ...interface{})
- type PGSqlMapConf
- type RedisConf
- type RedisMapConf
- type Trace
- type TraceContext
Constants ¶
View Source
const ( DLTagUndefind = "_undef" DLTagMySqlFailed = "_com_mysql_failure" DLTagRedisFailed = "_com_redis_failure" DLTagMySqlSuccess = "_com_mysql_success" DLTagRedisSuccess = "_com_redis_success" DLTagThriftFailed = "_com_thrift_failure" DLTagThriftSuccess = "_com_thrift_success" DLTagHTTPSuccess = "_com_http_success" DLTagHTTPFailed = "_com_http_failure" DLTagTCPFailed = "_com_tcp_failure" DLTagRequestIn = "_com_request_in" DLTagRequestOut = "_com_request_out" )
通用DLTag常量定义
Variables ¶
View Source
var ConfEnv string //配置环境名 比如:dev prod test
View Source
var ConfEnvPath string //配置文件夹
View Source
var DBDefaultPool *sql.DB
View Source
var DBMapPool map[string]*sql.DB
View Source
var DateFormat = "2006-01-02"
View Source
var DefaultMysqlGormLogger = MysqlGormLogger{ LogLevel: logger.Info, SlowThreshold: 200 * time.Millisecond, }
mysql 日志打印类型
View Source
var DefaultPGSqlGormLogger = PGSqlGormLogger{ LogLevel: logger.Info, SlowThreshold: 200 * time.Millisecond, }
DefaultPGSqlGormLogger postgresql 日志打印类型
View Source
var GORMDefaultPool *gorm.DB
View Source
var GORMMapPool map[string]*gorm.DB
View Source
var LocalIP = net.ParseIP("127.0.0.1")
View Source
var TimeFormat = "2006-01-02 15:04:05"
View Source
var TimeLocation *time.Location
View Source
var ViperConfMap map[string]*viper.Viper
Functions ¶
func DBPoolLogQuery ¶
func GetConfFilePath ¶
func GetConfPath ¶
func GetLocalIPs ¶
func GetMd5Hash ¶
func GetTraceId ¶
func GetTraceId() (traceId string)
func InArrayString ¶
func InitBaseConf ¶
func InitDBPool ¶
func InitRedisConf ¶
func PGDBPoolLogQuery ¶
func ParseConfPath ¶
解析配置文件目录
配置文件必须放到一个文件夹中 如:config=conf/dev/base.json ConfEnvPath=conf/dev ConfEnv=dev 如:config=conf/base.json ConfEnvPath=conf ConfEnv=conf
func ParseConfig ¶
func ParseServerAddr ¶
func RedisConfDo ¶
func RedisConfDo(trace *TraceContext, name string, commandName string, args ...interface{}) (interface{}, error)
通过配置 执行redis
func RedisLogDo ¶
func RedisLogDo(trace *TraceContext, c redis.Conn, commandName string, args ...interface{}) (interface{}, error)
func SetGinTraceContext ¶
func SetGinTraceContext(c *gin.Context, trace *TraceContext) error
func SetTraceContext ¶
func SetTraceContext(ctx context.Context, trace *TraceContext) context.Context
Types ¶
type BaseConf ¶
type BaseConf struct { DebugMode string `mapstructure:"debug_mode"` TimeLocation string `mapstructure:"time_location"` Log LogConfig `mapstructure:"log"` Base struct { DebugMode string `mapstructure:"debug_mode"` TimeLocation string `mapstructure:"time_location"` } `mapstructure:"base"` }
var ConfBase *BaseConf
全局变量
type LogConfConsoleWriter ¶
type LogConfFileWriter ¶
type LogConfig ¶
type LogConfig struct { Level string `mapstructure:"log_level"` FW LogConfFileWriter `mapstructure:"file_writer"` CW LogConfConsoleWriter `mapstructure:"console_writer"` }
type Logger ¶
type Logger struct { }
var Log *Logger
func (*Logger) TagDebug ¶
func (l *Logger) TagDebug(trace *TraceContext, dltag string, m map[string]interface{})
func (*Logger) TagError ¶
func (l *Logger) TagError(trace *TraceContext, dltag string, m map[string]interface{})
func (*Logger) TagInfo ¶
func (l *Logger) TagInfo(trace *TraceContext, dltag string, m map[string]interface{})
type MysqlGormLogger ¶
func (*MysqlGormLogger) Error ¶
func (mgl *MysqlGormLogger) Error(ctx context.Context, message string, values ...interface{})
func (*MysqlGormLogger) Info ¶
func (mgl *MysqlGormLogger) Info(ctx context.Context, message string, values ...interface{})
func (*MysqlGormLogger) LogMode ¶
func (mgl *MysqlGormLogger) LogMode(logLevel logger.LogLevel) logger.Interface
type MysqlMapConf ¶
type PGSqlConf ¶
type PGSqlConf struct { DriverName string `mapstructure:"driver_name"` Path string `mapstructure:"url"` Username string `mapstructure:"username"` Password string `mapstructure:"password"` Dbname string `mapstructure:"dbname"` Port string `mapstructure:"port"` Config string `mapstructure:"config"` MaxOpenConn int `mapstructure:"max_open_conn"` MaxIdleConn int `mapstructure:"max_idle_conn"` MaxConnLifeTime int `mapstructure:"max_conn_life_time"` }
type PGSqlGormLogger ¶
func (*PGSqlGormLogger) Error ¶
func (mgl *PGSqlGormLogger) Error(ctx context.Context, message string, values ...interface{})
func (*PGSqlGormLogger) Info ¶
func (mgl *PGSqlGormLogger) Info(ctx context.Context, message string, values ...interface{})
func (*PGSqlGormLogger) LogMode ¶
func (mgl *PGSqlGormLogger) LogMode(logLevel logger.LogLevel) logger.Interface
type PGSqlMapConf ¶
type RedisConf ¶
type RedisConf struct { ProxyList []string `mapstructure:"proxy_list"` Password string `mapstructure:"password"` Db int `mapstructure:"db"` ConnTimeout int `mapstructure:"conn_timeout"` ReadTimeout int `mapstructure:"read_timeout"` WriteTimeout int `mapstructure:"write_timeout"` }
var ConfRedis *RedisConf
type RedisMapConf ¶
var ConfRedisMap *RedisMapConf
type TraceContext ¶
func GetTraceContext ¶
func GetTraceContext(ctx context.Context) *TraceContext
func NewTrace ¶
func NewTrace() *TraceContext
Source Files ¶
Click to show internal directories.
Click to hide internal directories.