Documentation ¶
Index ¶
- Variables
- func Context(ctx context.Context) zapcore.Field
- func Label(key, val string) zapcore.Field
- func Metadata(ctx context.Context) zapcore.Field
- func Proto(key string, val proto.Message) zapcore.Field
- func Request(req HTTPRequestEntry) zapcore.Field
- func Slack(url ...string) zapcore.Field
- func Visitor(logger *zap.Logger) func(f *flag.Flag)
- func VisitorP(logger *zap.Logger) func(f *pflag.Flag)
- func Zap(level zapcore.Level, opts ...Option) *zap.Logger
- type HTTPRequestEntry
- type Option
Constants ¶
This section is empty.
Variables ¶
View Source
var (
RequestIDMetadataKey = "x-request-id"
)
View Source
var StackdriverEncoderConfig = zapcore.EncoderConfig{ MessageKey: "message", LevelKey: "severity", TimeKey: "eventTime", NameKey: "logger", CallerKey: "caller", StacktraceKey: "stacktrace", LineEnding: zapcore.DefaultLineEnding, EncodeLevel: func(lv zapcore.Level, enc zapcore.PrimitiveArrayEncoder) { var s string switch lv { case zapcore.DebugLevel: s = "DEBUG" case zapcore.InfoLevel: s = "INFO" case zapcore.WarnLevel: s = "WARNING" case zapcore.ErrorLevel: s = "ERROR" case zapcore.DPanicLevel: s = "CRITICAL" case zapcore.PanicLevel: s = "ALERT" case zapcore.FatalLevel: s = "EMERGENCY" } enc.AppendString(s) }, EncodeTime: zapcore.ISO8601TimeEncoder, EncodeDuration: zapcore.SecondsDurationEncoder, EncodeCaller: zapcore.ShortCallerEncoder, }
StackdriverEncoderConfig is a encoder config for stackdriver.
Functions ¶
func Request ¶
func Request(req HTTPRequestEntry) zapcore.Field
func Visitor ¶ added in v0.1.10
Visitor will dump all the flags to Info level logger. It will automatically redact sensitive fields, name of which contains `key, secret, password, dsn` keywords
Types ¶
type HTTPRequestEntry ¶
type HTTPRequestEntry struct { Request *http.Request RequestMethod string RequestURL string RequestSize int64 Status int ResponseSize int64 UserAgent string RemoteIP string Referer string Latency time.Duration }
HTTPRequestEntry is information about the HTTP request associated with this log entry. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#HttpRequest
func (HTTPRequestEntry) MarshalLogObject ¶
func (t HTTPRequestEntry) MarshalLogObject(e zapcore.ObjectEncoder) error
MarshalLogObject is ObjectMarshaler implementation.
type Option ¶
type Option func(*option)
func WithErrorParser ¶
func WithErrorParser(parser func(error) (zapcore.ObjectMarshaler, bool)) Option
func WithProjectID ¶
func WithService ¶
func WithVersion ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.