Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteObject(obj interface{}, fields []string) string
- func DeleteString(jsonStr []byte, fields []string) []byte
- func Error(c context.Context, err error, info string, fields ...interface{})
- func Fatal(c context.Context, err error, info string, fields ...interface{})
- func GetTrackId(c context.Context) string
- func Info(c context.Context, info string, fields ...interface{})
- func Init(logPath string)
- func LoopError(c context.Context, logId string, err error, info string, fields ...interface{})
- func LoopFatal(c context.Context, logId string, err error, info string, fields ...interface{})
- func LoopInfo(c context.Context, logId string, info string, fields ...interface{})
- func Middleware() gin.HandlerFunc
- func NewContext() context.Context
- func NewTrackId() string
- func RemoveLogId(logId string)
- func ReplaceObject(obj interface{}, replaceStr string, fields []string) string
- func ReplaceString(jsonStr []byte, replaceStr string, fields []string) []byte
- func SetRouterConfig(method string, baseUrl string, apiUrl string, config RouterConfig)
- func SetRouterConfigDirectly(method string, urlPath string, config RouterConfig)
- func SetRouterMethodDisabled(method string, status bool)
- type ContextHook
- type ResponseBodyWriter
- type RouterConfig
Constants ¶
View Source
const IgnoreReplaceStr = "-"
忽略时替换为的字符串
View Source
const KEY_ID = "TRACKIDENTIFIER"
内部记录TrackId时使用的Key值
Variables ¶
View Source
var GlobalRouterConfig = RouterConfig{ DisableReq: false, DisableRsp: false, HeaderFields: nil, IgnoreReqBodyFields: nil, IgnoreRspFields: nil, OutputReqBody: nil, }
全局配置项
View Source
var (
Interval = int64(60) // 输出间隔,单位为秒,默认间隔60秒输出
)
Functions ¶
func DeleteObject ¶
删除通用对象指定字段,必须是可以Json序列化的对象
func RemoveLogId ¶
func RemoveLogId(logId string)
func ReplaceObject ¶
替换通用对象指定字段,必须是可以Json序列化的对象
func ReplaceString ¶
替换Json字符串指定字段
func SetRouterConfig ¶
func SetRouterConfig( method string, baseUrl string, apiUrl string, config RouterConfig, )
设置自定义映射信息
func SetRouterConfigDirectly ¶
func SetRouterConfigDirectly( method string, urlPath string, config RouterConfig, )
设置自定义映射信息
Types ¶
type ContextHook ¶
type ContextHook struct{}
func (*ContextHook) Levels ¶
func (hook *ContextHook) Levels() []logrus.Level
type ResponseBodyWriter ¶
type ResponseBodyWriter struct { gin.ResponseWriter Body *bytes.Buffer }
用于替换应答Writer的,记录返回信息
type RouterConfig ¶
type RouterConfig struct { DisableReq bool // 禁用请求 DisableRsp bool // 禁用应答 HeaderFields []string // (通用) 输出的header字段 IgnoreReqBodyFields []string // 忽略的body字段,不同的Content-Type对应不同的处理 IgnoreRspFields []string // 忽略的rsp字段,不同的Content-Type对应不同的处理 OutputReqBody func(*gin.Context, string) string // 自定义输出请求的body函数 }
路由配置信息项
Click to show internal directories.
Click to hide internal directories.