Documentation ¶
Index ¶
- Constants
- Variables
- func AddGetDataToUrl(urlString string, params url.Values) string
- func CloseDB() error
- func CreateBizNLTag(tagName string) string
- func DBPoolLogQuery(trace *TraceContext, sqlDB *sql.DB, query string, args ...interface{}) (*sql.Rows, error)
- func Destroy()
- 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 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, urlStrings 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 InitRedisConf(path string) error
- func InitViperConf() error
- func IsSetConf(key string) bool
- func NewSpanId() string
- func ParseConfig(path string, conf interface{}) error
- func ParseConfigPath(config string) error
- func ParseLocalConfig(fileName string, conf interface{}) error
- 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 LoggerFaced
- func (l *LoggerFaced) Close()
- func (l *LoggerFaced) TagDebug(trace *TraceContext, nltag string, m map[string]interface{})
- func (l *LoggerFaced) TagError(trace *TraceContext, nltag string, m map[string]interface{})
- func (l *LoggerFaced) TagInfo(trace *TraceContext, nltag string, m map[string]interface{})
- func (l *LoggerFaced) TagTrace(trace *TraceContext, nltag string, m map[string]interface{})
- func (l *LoggerFaced) TagWarn(trace *TraceContext, nltag string, m map[string]interface{})
- type MysqlConf
- type MysqlConfMap
- type MysqlGormLogger
- func (m MysqlGormLogger) Error(ctx context.Context, message string, values ...interface{})
- func (m MysqlGormLogger) Info(ctx context.Context, s string, i ...interface{})
- func (m MysqlGormLogger) LogMode(level logger.LogLevel) logger.Interface
- func (m MysqlGormLogger) Trace(ctx context.Context, begin time.Time, ...)
- func (m MysqlGormLogger) Warn(ctx context.Context, s string, i ...interface{})
- type RedisConf
- type RedisConfMap
- type Trace
- type TraceContext
Constants ¶
View Source
const ( NLTagUndefined = "_undef" NLTagMySqlFailed = "_com_mysql_failure" NLTagRedisFailed = "_com_redis_failure" NLTagMySqlSuccess = "_com_mysql_success" NLTagRedisSuccess = "_com_redis_success" NLTagThriftFailed = "_com_thrift_failure" NLTagThriftSuccess = "_com_thrift_success" NLTagHTTPSuccess = "_com_http_success" NLTagHTTPFailed = "_com_http_failure" NLTagTCPFailed = "_com_tcp_failure" NLTagRequestIn = "_com_request_in" NLTagRequestOut = "_com_request_out" )
Variables ¶
View Source
var ConfEnv string
View Source
var ConfEnvPath string
View Source
var DBDefaultPool *sql.DB
View Source
var DBMapPool map[string]*sql.DB
View Source
var DateFormat = "2024-05-11"
View Source
var DefaultMysqlGormLogger = MysqlGormLogger{ LogLevel: logger.Info, SlowThreshold: 200 * time.Millisecond, }
mysql 日志打印类型
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 = "2024-05-11 10:32:00"
View Source
var TimeLocation *time.Location
View Source
var ViperConfMap map[string]*viper.Viper
Functions ¶
func CreateBizNLTag ¶
func DBPoolLogQuery ¶
func GetBoolConf ¶
func GetConfEnv ¶
func GetConfEnv() string
func GetConfFilePath ¶
func GetConfPath ¶
func GetLocalIPs ¶
func GetStringConf ¶
func GetStringMapConf ¶
func GetTraceId ¶
func GetTraceId() (traceId string)
func InArrayString ¶
func InitBaseConf ¶
func InitDBPool ¶
func InitModule ¶
func InitRedisConf ¶
func InitViperConf ¶
func InitViperConf() error
func ParseConfig ¶
func ParseLocalConfig ¶
func RedisConfDo ¶
func RedisConfDo(trace *TraceContext, name string, commandName string, args ...interface{}) (interface{}, error)
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
func GetBaseConf ¶
func GetBaseConf() *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 LoggerFaced ¶
type LoggerFaced struct { }
var Log *LoggerFaced
func (*LoggerFaced) Close ¶
func (l *LoggerFaced) Close()
func (*LoggerFaced) TagDebug ¶
func (l *LoggerFaced) TagDebug(trace *TraceContext, nltag string, m map[string]interface{})
func (*LoggerFaced) TagError ¶
func (l *LoggerFaced) TagError(trace *TraceContext, nltag string, m map[string]interface{})
func (*LoggerFaced) TagInfo ¶
func (l *LoggerFaced) TagInfo(trace *TraceContext, nltag string, m map[string]interface{})
func (*LoggerFaced) TagTrace ¶
func (l *LoggerFaced) TagTrace(trace *TraceContext, nltag string, m map[string]interface{})
func (*LoggerFaced) TagWarn ¶
func (l *LoggerFaced) TagWarn(trace *TraceContext, nltag string, m map[string]interface{})
type MysqlConfMap ¶
type MysqlGormLogger ¶
func (MysqlGormLogger) Error ¶
func (m MysqlGormLogger) Error(ctx context.Context, message string, values ...interface{})
func (MysqlGormLogger) Info ¶
func (m MysqlGormLogger) Info(ctx context.Context, s string, i ...interface{})
func (MysqlGormLogger) LogMode ¶
func (m MysqlGormLogger) LogMode(level logger.LogLevel) logger.Interface
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 RedisConfMap ¶
var ConfRedisMap *RedisConfMap
type TraceContext ¶
func GetTraceContext ¶
func GetTraceContext(ctx context.Context) *TraceContext
func NewTrace ¶
func NewTrace() *TraceContext
Click to show internal directories.
Click to hide internal directories.