Documentation
¶
Index ¶
- Constants
- Variables
- func AddNotice(ctx context.Context, key string, val interface{})
- func CloseLogger()
- func Debug(ctx context.Context, args ...interface{})
- func DebugLogger(ctx context.Context, msg string, fields ...zap.Field)
- func Debugf(ctx context.Context, format string, args ...interface{})
- func Error(ctx context.Context, args ...interface{})
- func ErrorLogger(ctx context.Context, msg string, fields ...zap.Field)
- func Errorf(ctx context.Context, format string, args ...interface{})
- func Fatal(ctx context.Context, args ...interface{})
- func FatalLogger(ctx context.Context, msg string, fields ...zap.Field)
- func Fatalf(ctx context.Context, format string, args ...interface{})
- func GetCustomKV(ctx context.Context, key string) string
- func GetCustomerKeyValue(ctx context.Context) map[string]interface{}
- func GetExternalAddress(ctx context.Context) string
- func GetKeyURI(ctx context.Context) string
- func GetLogID(ctx context.Context) string
- func GetLogger() (s *zap.SugaredLogger)
- func GetMachineID(ctx context.Context) string
- func GetRequestID(ctx context.Context) string
- func GetTenantID(ctx context.Context) int64
- func GetUserAuthGroup(ctx context.Context) string
- func GetUserAuthGroupListByReqCtx(ctx context.Context) (ctxGroupList []int64)
- func GetUserID(ctx context.Context) int64
- func GetZapLogger() (l *zap.Logger)
- func Info(ctx context.Context, args ...interface{})
- func InfoLogger(ctx context.Context, msg string, fields ...zap.Field)
- func Infof(ctx context.Context, format string, args ...interface{})
- func InitLog(conf LogConfig) *zap.SugaredLogger
- func NewEntry(s *zap.SugaredLogger) *entry
- func NewNNJSONEncoder(cfg zapcore.EncoderConfig) zapcore.Encoder
- func NoLog(ctx context.Context, lvl zapcore.Level) bool
- func Panic(ctx context.Context, args ...interface{})
- func PanicLogger(ctx context.Context, msg string, fields ...zap.Field)
- func Panicf(ctx context.Context, format string, args ...interface{})
- func RegisterNNJSONEncoder() error
- func SetNoLogFlag(ctx context.Context)
- func Warn(ctx context.Context, args ...interface{})
- func WarnLogger(ctx context.Context, msg string, fields ...zap.Field)
- func Warnf(ctx context.Context, format string, args ...interface{})
- type Field
- type Fields
- type LogConfig
- type LogRateConf
- type XTCPLogger
Constants ¶
View Source
const ( TopicType = "_tp" LogNameServer = "server" LogNameAccess = "access" LogNameModule = "module" )
View Source
const ( ContextKeyRequestID = "requestId" ContextKeyLogID = "logId" ContextKeyNoLog = "_no_log" ContextKeyUri = "_uri" ContextKeyUserID = "userId" ContextKeyTenantID = "tenantId" ContextKeyMachineID = "machineId" ContextKeyExternalAddr = "externalAddr" ContextKeyUserAuthGroup = "userAuthGroup" )
util key
View Source
const ( TraceHeaderKey = "Uber-Trace-Id" LogIDHeaderKey = "X_BD_LOGID" LogIDHeaderKeyLower = "x_bd_logid" )
header key
View Source
const ContextValAllAuthGroup = "-1" // 所有分组权限都有
View Source
const ContextValNoAuthGroup = "-2" // 所有分组权限都没有
View Source
const (
StartTime = "startTime"
)
rpcx 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 GetExternalAddress ¶
func GetLogger ¶
func GetLogger() (s *zap.SugaredLogger)
GetLogger 获得一个新的logger 会把日志打印到 name.log 中,不建议业务使用 deprecated
func GetMachineID ¶
func GetRequestID ¶
func GetTenantID ¶
func GetUserAuthGroup ¶
func GetUserAuthGroupListByReqCtx ¶
GetUserAuthGroupListByReqCtx 从请求上下文里获取主机分组权限 优先从请求过来的rpcx上下文中获取- 此种情况为正常的上游rpc请求 上面没有则直接从上下文里获取key - 此种情况一般为mq或定时任务 业务方使用的
func GetZapLogger ¶
func InitLog ¶
func InitLog(conf LogConfig) *zap.SugaredLogger
func NewEntry ¶
func NewEntry(s *zap.SugaredLogger) *entry
func NewNNJSONEncoder ¶
func NewNNJSONEncoder(cfg zapcore.EncoderConfig) zapcore.Encoder
func RegisterNNJSONEncoder ¶
func RegisterNNJSONEncoder() error
RegisterNNJSONEncoder registers a special jsonEncoder under "zyb-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"`
LogRate bool `yaml:"logRate"`
LogRateConf LogRateConf `yaml:"logRateConf"`
}
type LogRateConf ¶
type LogRateConf struct {
MaxAge int `yaml:"maxAge"`
MaxBackups uint `yaml:"maxBackups"`
MaxSize uint `yaml:"maxSize"`
}
LogRateConf log rate config
type XTCPLogger ¶
type XTCPLogger struct {
}
func GetXTCPLogger ¶
func GetXTCPLogger() *XTCPLogger
func (XTCPLogger) Log ¶
func (XTCPLogger) Log(l xtcp.LogLevel, v ...interface{})
Click to show internal directories.
Click to hide internal directories.