logging

package
v0.0.0-...-87f5de6 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fatal

func Fatal(logger Logger, keyvals ...interface{})

Fatal is an effective copy of go's log.Fatal, but using the logger provided, rather than using go's native logging. After writing the message, the code will exit with code 1

func Log

func Log(ctx context.Context, keyvals ...interface{}) error

Log provides a shorthand for the following code: ReqLogger(myContext).Log(/*your values here*/)

func SetSystemLogger

func SetSystemLogger(logger Logger)

func SystemLog

func SystemLog(keyvals ...interface{}) error

SystemLog provides a system-level logger, which is not tied to any request. this should be used in situations where either a context is not handy, but logging is important or for events that are not tied to a request (e.g. losing database connection)

Types

type Logger

type Logger kitlog.Logger

Logger is a generic logging interface. Currently wraps Go-kit's log.Logger

func AddRequestLogger

func AddRequestLogger(ctx context.Context, baseLogger Logger) (context.Context, Logger)

AddRequestLogger adds a logger to this request. The logger will provide unique identification for any request in this stream (via the "ctx" field in the log). The logger can be retrieved via

func GetSystemLogger

func GetSystemLogger() Logger

func NewNopLogger

func NewNopLogger() Logger

NewNopLogger creates a logger that actually does not log. useful in situations where some logger is needed, but for whatever reason, a real logger is missing (or if you want to conditionally) disable logging.

func ReqLogger

func ReqLogger(ctx context.Context) Logger

ReqLogger retrieves a stored initially stored with AddRequestLogger. This logger is tied to the request (or more specifically, the context). Assuming you only have a request handy, the code to retrieve the logger is: logging.ReqLogger(r.Context())

func SetupStdoutLogging

func SetupStdoutLogging() Logger

SetupStdoutLogging creates a new logger that logs to standard out

Jump to

Keyboard shortcuts

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