Documentation ¶
Index ¶
- Variables
- func LogErrorWithBody(ctx context.Context, err error, errName, responseBody string)
- func NewKievRequestLogger(appName string) func(http.HandlerFunc) http.HandlerFunc
- type Context
- type Level
- type LoggedEvent
- type Logger
- func Get(ctx context.Context) Logger
- func New(ctx context.Context, appName string) (Logger, context.Context)
- func NewLambdaLogger(ctx context.Context) (Logger, context.Context)
- func NewRequestLogger(appName string, req *http.Request) (Logger, context.Context)
- func NewStandalone(appName string) (Logger, context.Context)
Constants ¶
This section is empty.
Variables ¶
var DefaultLogger defaultLogger
DefaultLogger represents everywhere available logger with default LogSink. It is also used with package logger.Event(...) method executions.
var LogSink io.Writer
LogSink points to the writer that store all logs, default one is os.Stdout If you want to have it different, just set it prior using any `logger.New*(...)` function
Functions ¶
func LogErrorWithBody ¶
LogErrorWithBody updates logging context with details of the error and responseBody payload. This is later dumped with the request_finished event
func NewKievRequestLogger ¶
func NewKievRequestLogger(appName string) func(http.HandlerFunc) http.HandlerFunc
NewKievRequestLogger creates a middleware that can wrap `http.HandlerFunc` of your server with logger inside of the `request.Context()`.
Types ¶
type LoggedEvent ¶ added in v0.1.0
LoggedEvent is a type-alias for zerolog.Event
func Error ¶ added in v0.2.0
func Error(name string, err error) *LoggedEvent
Event package function logs message with DefaultLogger on loglevel error
func Event ¶
func Event(name string) *LoggedEvent
Event package function logs message with DefaultLogger
type Logger ¶ added in v0.1.0
type Logger interface { WithScope(map[string]interface{}) IsDisabled() bool // contains filtered or unexported methods }
Logger is an interface for the returned logger instance
func Get ¶
Get returns Logger instance from the argument representing current `context.Context`. Useful to get the logger instance downstream somewhere deep in your app. Then you pass just the context instance all way down and get the `Logger` out using this function.
func New ¶ added in v0.1.0
New creates a logger with appName specified and attaches it to the provided ctx and the enriched context is returned as second value. If already logger exists in the context it returns it as it is.
func NewLambdaLogger ¶ added in v0.1.0
NewLambdaLogger returns a logger and enhanced context which is ready to log details of request in JSON responses compatible with Kiev format.
func NewRequestLogger ¶
NewRequestLogger registers logger on the request and it's context and loads the logger scope from the request context.