Documentation ¶
Index ¶
- Variables
- func GetTraceIDFromContext(ctx context.Context) string
- func GetTraceIDFromGrpcMetadata(md metadata.MD) string
- func GetTraceIDFromHTTPHeader(header http.Header) string
- func L(ctx context.Context) *zap.Logger
- func New(conf Config) (*zap.Logger, error)
- func NewCtxWithTraceID(ctx context.Context) context.Context
- func NewTraceID() string
- func S(ctx context.Context) *zap.SugaredLogger
- func TraceIDField(ctx context.Context) zap.Field
- type Config
- type EncodeKeyConfig
- type FileLogConfig
- type ID
- type TraceKey
Constants ¶
This section is empty.
Variables ¶
View Source
var SystemKey = "system"
View Source
var SystemName = "system"
View Source
var SystemTraceName = "system"
Functions ¶
func GetTraceIDFromContext ¶
GetTraceIDFromContext GetTraceIDFromContext
func GetTraceIDFromGrpcMetadata ¶
GetTraceIDFromGrpcMetadata GetTraceIDFromGrpcMetadata case insensitive
func GetTraceIDFromHTTPHeader ¶
GetTraceIDFromHTTPHeader GetTraceIDFromHTTPHeader
func NewCtxWithTraceID ¶
NewCtxWithTraceID NewCtxWithTraceID
Types ¶
type Config ¶
type Config struct { // 业务服务名称,如果多个业务日志在ELK中聚合,此字段就有用了 ServiceName string `yaml:"serviceName"` // 日志级别. Level string `yaml:"level"` // 日志级别字段开启颜色功能 LevelColor bool `yaml:"levelColor"` // Log format. one of json or plain. Format string `yaml:"format"` // 是否输出到控制台. Stdout bool `yaml:"stdout"` // File log config. File FileLogConfig `yaml:"file"` //EncodeKey EncodeKeys EncodeKey EncodeKeyConfig `yaml:"encodeKey"` //SentryDSN Sentry 的 DSN地址,如果配置了此参数,warn 级别以上的错误会发送sentry SentryDSN string `yaml:"sentryDSN"` //SystemName 系统名称 SystemName string `yaml:"systemName"` //SystemTraceName 系统日志(非业务相关) traceID 对应的值 SystemTraceName string `yaml:"systemTraceName"` }
type EncodeKeyConfig ¶
type EncodeKeyConfig struct { // TimeKey format. TimeKey string `yaml:"timeKey"` // LevelKey format. LevelKey string `yaml:"levelKey"` // NameKey format. NameKey string `yaml:"nameKey"` // CallerKey format. CallerKey string `yaml:"callerKey"` // MessageKey format. MessageKey string `yaml:"messageKey"` //StacktraceKey StacktraceKey StacktraceKey string `yaml:"stacktraceKey"` }
type FileLogConfig ¶
type FileLogConfig struct { // Filename 日志文件路径. Filename string `yaml:"filename"` // LogRotate Is log rotate enabled. LogRotate bool `yaml:"logRotate"` // MaxSize size for a single file, in MB. MaxSize int `yaml:"maxSize"` // MaxAge log keep days, default is never deleting. MaxAge int `yaml:"maxAge"` // MaxBackups number of old log files to retain. MaxBackups int `yaml:"maxBackups"` // BufSize size of bufio.Writer BufSize int `yaml:"bufSize"` }
FileLogConfig serializes file log related config.
Click to show internal directories.
Click to hide internal directories.