logger

package
v0.0.0-...-4a0794a Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromCtx

func FromCtx(ctx context.Context) jimu.Logger

FromCtx implement jimu.LoggerGetter

Types

type Logger

type Logger zerolog.Logger

Logger adapt zerolog's logger to Logger interface.

func (*Logger) Log

func (l *Logger) Log(keyvals ...interface{}) error

Log implement jimu.Logger interface. NOTE: the first key/value pair should be ("level", "debug"/"info"/"warn"...), otherwise the level will set to "info" even it appears later.

type LoggerManager

type LoggerManager struct {
	// contains filtered or unexported fields
}

LoggerManager adds zerolog's json logger to context and log http requests.

func New

func New() *LoggerManager

New create LoggerManager.

func (*LoggerManager) Configure

func (m *LoggerManager) Configure() error

Configure the manager. Options are not allowed to add after configure.

func (*LoggerManager) Options

func (m *LoggerManager) Options(options ...Option)

Options add options to the manager.

func (*LoggerManager) Wrap

func (m *LoggerManager) Wrap(next http.Handler) http.Handler

Wrap is the middleware.

type Option

type Option func(*LoggerManager) error

Option is the option of LoggerManager.

func ExtraField

func ExtraField(field string, fieldExtractor func(*http.Request) string) Option

ExtraField add an extra field to log for a http request.

func HasConsoleColor

func HasConsoleColor(hasColor bool) Option

HasConsoleColor set color setting when IsConsole is true.

func IsConsole

func IsConsole() Option

IsConsole indicate to use zerolog.ConsoleWriter.

func Output

func Output(w io.Writer) Option

Output set logging's output.

Jump to

Keyboard shortcuts

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