logging

package
v0.0.0-...-412dc8c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2021 License: Apache-2.0, MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(config interfaces.AppConfig) (*zap.Logger, error)

Configure Setup zap logging and return the root logger.

func ZapFieldsFromContext

func ZapFieldsFromContext(ctx context.Context) []zap.Field

ZapFieldsFromContext Extract public fields from the context and return them as a list of zap.Field objects.

This is to make structured logging work well. In the body of request handlers, the following code can be used to attach request-related data to the route logger:

```

func LoginHandler(req interfaces.RequestContext) *views.Response {
    logger := req.Logger().With(logging.ZapFieldsFromContext(req.Context()))
    // now, the request id and other metadata will automatically be included in future logs
}

```

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL