Documentation ¶
Index ¶
- Constants
- func RotateWriter(infoFile, errFile string) (infoWriter io.Writer, errWriter io.Writer, err error)
- func ValueLogID(ctx context.Context) string
- func ValueTraceID(ctx context.Context) string
- func WithHTTPFields(ctx context.Context, fields Fields) context.Context
- func WithLogID(ctx context.Context, val interface{}) context.Context
- func WithTraceID(ctx context.Context, val interface{}) context.Context
- type Config
- type Fields
- type Logger
- func (l *Logger) Debug(ctx context.Context, msg string, fields ...zap.Field)
- func (l *Logger) Error(ctx context.Context, msg string, fields ...zap.Field)
- func (l *Logger) Fatal(ctx context.Context, msg string, fields ...zap.Field)
- func (l *Logger) GetLevel() zapcore.Level
- func (l *Logger) Info(ctx context.Context, msg string, fields ...zap.Field)
- func (l *Logger) Warn(ctx context.Context, msg string, fields ...zap.Field)
- type ObjectId
- type Option
- type Options
Constants ¶
const ( ModuleHTTP = "HTTP" ModuleRPC = "RPC" ModuleMySQL = "MySQL" ModuleRedis = "Redis" ModuleRabbitMQ = "RabbitMQ" ModuleCron = "Cron" )
const ( LogID = "log_id" TraceID = "trace_id" Header = "header" Method = "method" Request = "request" Response = "response" Code = "code" ClientIP = "client_ip" ClientPort = "client_port" ServerIP = "server_ip" ServerPort = "server_port" API = "api" Cost = "cost" Module = "module" SericeName = "service_name" Timeout = "timeout" Trace = "trace" )
const (
LogHeader = "Log-Id"
)
Variables ¶
This section is empty.
Functions ¶
func RotateWriter ¶ added in v1.0.22
func ValueLogID ¶
ValueLogID extract log id from context
func ValueTraceID ¶
ValueTraceID extract trace id from context
func WithHTTPFields ¶
WithHTTPFields inject common http log fields to context
Types ¶
type Fields ¶
type Fields struct { LogID string `json:"log_id"` TraceID string `json:"trace_id"` Header http.Header `json:"header"` Method string `json:"method"` Request interface{} `json:"request"` Response interface{} `json:"response"` Code int `json:"code"` ClientIP string `json:"client_ip"` ClientPort int `json:"client_port"` ServerIP string `json:"server_ip"` ServerPort int `json:"server_port"` API string `json:"api"` Cost int64 `json:"cost"` }
func ValueHTTPFields ¶
ValueHTTPFields extrect common http log fields from context
type ObjectId ¶
type ObjectId [12]byte
LogId is a unique ID identifying a log record. It must be exactly 12 bytes long.
Reference:http://www.mongodb.org/display/DOCS/Object+IDs
func NewObjectIdWithTime ¶
NewObjectIdWithTime returns a dummy ObjectId with the timestamp part filled with the provided number of seconds from epoch UTC, and all other parts filled with zeroes. It's not safe to insert a document with an id generated by this method, it is useful only for queries to find documents with ids generated before or after the specified timestamp.
func StrToObjectId ¶
StrToObjectId string id to object
func (ObjectId) Counter ¶
Counter returns the incrementing value part of the id. It's a runtime error to call this method with an invalid id.
func (ObjectId) Machine ¶
Machine returns the 3-byte machine id part of the id. It's a runtime error to call this method with an invalid id.
type Option ¶
type Option func(l *Options)