Documentation ¶
Index ¶
- Constants
- Variables
- func AddNotice(ctx *gin.Context, key string, val interface{})
- func CloseLogger()
- func Debug(ctx *gin.Context, args ...interface{})
- func DebugLogger(ctx *gin.Context, msg string, fields ...zap.Field)
- func Debugf(ctx *gin.Context, format string, args ...interface{})
- func Error(ctx *gin.Context, args ...interface{})
- func ErrorLogger(ctx *gin.Context, msg string, fields ...zap.Field)
- func Errorf(ctx *gin.Context, format string, args ...interface{})
- func Fatal(ctx *gin.Context, args ...interface{})
- func FatalLogger(ctx *gin.Context, msg string, fields ...zap.Field)
- func Fatalf(ctx *gin.Context, format string, args ...interface{})
- func GetCustomerKeyValue(ctx *gin.Context) map[string]interface{}
- func GetLogger() (s *zap.SugaredLogger)
- func GetRequestID(ctx *gin.Context) string
- func GetZapLogger() (l *zap.Logger)
- func Info(ctx *gin.Context, args ...interface{})
- func InfoLogger(ctx *gin.Context, msg string, fields ...zap.Field)
- func Infof(ctx *gin.Context, format string, args ...interface{})
- func InitLog(conf LogConfig) *zap.SugaredLogger
- func NewCsseJSONEncoder(cfg zapcore.EncoderConfig) zapcore.Encoder
- func NewEntry(s *zap.SugaredLogger) *entry
- func NoLog(ctx *gin.Context) bool
- func Panic(ctx *gin.Context, args ...interface{})
- func PanicLogger(ctx *gin.Context, msg string, fields ...zap.Field)
- func Panicf(ctx *gin.Context, format string, args ...interface{})
- func PrintNotice(ctx *gin.Context)
- func RegisterCsseJSONEncoder() error
- func SetNoLogFlag(ctx *gin.Context)
- func Warn(ctx *gin.Context, args ...interface{})
- func WarnLogger(ctx *gin.Context, msg string, fields ...zap.Field)
- func Warnf(ctx *gin.Context, format string, args ...interface{})
- type Buffer
- type Field
- type Fields
- type LogConfig
- type Rotate
- type TimeFileLogWriter
Constants ¶
View Source
const ( // trace 日志前缀标识(放在[]zap.Field的第一个位置提高效率) TopicType = "_tp" // 业务日志名字 LogNameServer = "server" // access 日志文件名字 LogNameAccess = "access" // module 日志文件名字 LogNameModule = "module" )
View Source
const ( ContextKeyRequestID = "requestId" ContextKeyLogID = "logID" ContextKeyNoLog = "_no_log" ContextKeyUri = "_uri" )
util key
View Source
const ( TraceHeaderKey = "Uber-Trace-Id" LogIDHeaderKey = "X_BD_LOGID" LogIDHeaderKeyLower = "x_bd_logid" )
header key
Variables ¶
View Source
var ( Binary = zap.Binary Bool = zap.Bool ByteString = zap.ByteString String = zap.String Strings = zap.Strings Float64 = zap.Float64 Float32 = zap.Float32 Int = zap.Int Int64 = zap.Int64 Int32 = zap.Int32 Int16 = zap.Int16 Int8 = zap.Int8 Uint = zap.Uint Uint64 = zap.Uint64 Uint32 = zap.Uint32 Reflect = zap.Reflect Namespace = zap.Namespace Duration = zap.Duration Object = zap.Object Any = zap.Any Skip = zap.Skip() )
View Source
var ( SugaredLogger *zap.SugaredLogger ZapLogger *zap.Logger )
Functions ¶
func CloseLogger ¶
func CloseLogger()
func GetCustomerKeyValue ¶
获得所有用户自定义的Notice
func GetLogger ¶
func GetLogger() (s *zap.SugaredLogger)
GetLogger 获得一个新的logger 会把日志打印到 name.log 中,不建议业务使用 deprecated
func GetRequestID ¶
func GetZapLogger ¶
func InitLog ¶
func InitLog(conf LogConfig) *zap.SugaredLogger
func NewCsseJSONEncoder ¶
func NewCsseJSONEncoder(cfg zapcore.EncoderConfig) zapcore.Encoder
func NewEntry ¶
func NewEntry(s *zap.SugaredLogger) *entry
func RegisterCsseJSONEncoder ¶
func RegisterCsseJSONEncoder() error
RegisterCsseJSONEncoder registers a special jsonEncoder under "csse-json" name.
func SetNoLogFlag ¶
Types ¶
type Fields ¶
type Fields map[string]interface{}
-------------避免用户改动过大,以下为封装的之前的Entry打印field的方法----------
type LogConfig ¶
type LogConfig struct { Level string `yaml:"level"` Stdout bool `yaml:"stdout"` Log2File bool `yaml:"log2file"` Path string `yaml:"path"` Rotate Rotate `yaml:"rotate"` Buffer Buffer `yaml:"buffer"` }
日志切分相关的log配置,仅虚拟机线上支持
type Rotate ¶
type Rotate struct { Switch bool `yaml:"switch"` Unit string `yaml:"unit"` Count int `yaml:"count"` }
对用户暴露的log配置
type TimeFileLogWriter ¶
type TimeFileLogWriter struct {
// contains filtered or unexported fields
}
This log writer sends output to a file
func NewTimeFileLogWriter ¶
func NewTimeFileLogWriter(fName string) *TimeFileLogWriter
Click to show internal directories.
Click to hide internal directories.