Documentation
¶
Index ¶
Constants ¶
View Source
const DefaultLoggerName = "default"
Variables ¶
View Source
var LogEncodingConfig = zapcore.EncoderConfig{ TimeKey: "time", LevelKey: "level", NameKey: "logger", CallerKey: "caller", FunctionKey: zapcore.OmitKey, MessageKey: "message", StacktraceKey: "stacktrace", LineEnding: zapcore.DefaultLineEnding, EncodeLevel: zapcore.CapitalLevelEncoder, EncodeTime: zapcore.ISO8601TimeEncoder, EncodeDuration: zapcore.StringDurationEncoder, EncodeCaller: zapcore.ShortCallerEncoder, NewReflectedEncoder: UseJSONReflectedEncoder, }
LogEncodingConfig represents the log encoding configuration
Functions ¶
func UseJSONReflectedEncoder ¶
func UseJSONReflectedEncoder(w io.Writer) zapcore.ReflectedEncoder
UseJSONReflectedEncoder returns a zapcore.ReflectedEncoder using json parser
Types ¶
type LogEvent ¶
type LogEvent struct { Message string `json:"message,omitempty" yaml:"message,omitempty"` // Message contains the log message. ID string `json:"id,omitempty" yaml:"id,omitempty"` // ID contains the unique identifier of the log event. IP string `json:"ip,omitempty" yaml:"ip,omitempty"` // IP contains the IP address of the client. EndPoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"` // EndPoint contains the endpoint of the request. Path string `json:"path,omitempty" yaml:"path,omitempty"` // Path contains the path of the request. Method string `json:"method,omitempty" yaml:"method,omitempty"` // Method contains the HTTP method of the request. Code int `json:"statusCode,omitempty" yaml:"statusCode,omitempty"` // Code contains the HTTP status code of the response. Status string `json:"status,omitempty" yaml:"status,omitempty"` // Status contains the status message of the response. Latency string `json:"latency,omitempty" yaml:"latency,omitempty"` // Latency contains the request latency. Agent string `json:"agent,omitempty" yaml:"agent,omitempty"` // Agent contains the user agent of the client. ReqContentType string `json:"reqContentType,omitempty" yaml:"reqContentType,omitempty"` // ReqContentType contains the content type of the request. ReqQuery string `json:"query,omitempty" yaml:"query,omitempty"` // ReqQuery contains the query parameters of the request. ReqBody string `json:"reqBody,omitempty" yaml:"reqBody,omitempty"` // ReqBody contains the request body. Error any `json:"error,omitempty" yaml:"error,omitempty"` // Error contains the error object. ErrorStack string `json:"errorStack,omitempty" yaml:"errorStack,omitempty"` // ErrorStack contains the stack trace of the error. }
LogEvent represents a log event.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func NewLogger ¶
func NewLogger(ws zapcore.WriteSyncer, opts ...zap.Option) *Logger
NewLogger creates a new logger
func (*Logger) GetLogrLogger ¶
GetLogrLogger returns the logr logger
func (*Logger) GetStdLogger ¶
GetStdLogger returns the standard library logger
func (*Logger) GetZapLogger ¶
GetZapLogger returns the zap logger
func (*Logger) GetZapSugaredLogger ¶
func (l *Logger) GetZapSugaredLogger() *zap.SugaredLogger
GetZapSugaredLogger returns the zap logger sugar
Click to show internal directories.
Click to hide internal directories.