watermillzap

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: MIT Imports: 2 Imported by: 3

README

GoDoc Release Go Report Card workflows codecov

watermillzap

watermillzap provides the implementation of watermill.LoggerAdapter using go.uber.org/zap.

Notice

Trace writes debug log instead of trace log because zap does not support trace level logging.

Documentation

Overview

Package watermillzap provides the implementation of watermill.LoggerAdapter using go.uber.org/zap.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(z *zap.Logger) watermill.LoggerAdapter

NewLogger returns new watermill.LoggerAdapter using passed *zap.Logger as backend.

Types

type Logger

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

Logger implements watermill.LoggerAdapter with *zap.Logger.

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields watermill.LogFields)

Debug writes debug log with message and some fields.

Example
logger := NewLogger(zap.NewExample())
logger.Debug("ExampleLogger_Debug", watermill.LogFields{"test_field": 1})
Output:

{"level":"debug","msg":"ExampleLogger_Debug","test_field":1}

func (*Logger) Error

func (l *Logger) Error(msg string, err error, fields watermill.LogFields)

Error writes error log with message, error and some fields.

Example
logger := NewLogger(zap.NewExample())
logger.Error("ExampleLogger_Error", errors.New("test error"), watermill.LogFields{"test_field": 1})
Output:

{"level":"error","msg":"ExampleLogger_Error","error":"test error","test_field":1}

func (*Logger) Info

func (l *Logger) Info(msg string, fields watermill.LogFields)

Info writes info log with message and some fields.

Example
logger := NewLogger(zap.NewExample())
logger.Info("ExampleLogger_Info", watermill.LogFields{"test_field": 1})
Output:

{"level":"info","msg":"ExampleLogger_Info","test_field":1}

func (*Logger) Trace

func (l *Logger) Trace(msg string, fields watermill.LogFields)

Trace writes debug log instead of trace log because zap does not support trace level logging.

Example
logger := NewLogger(zap.NewExample())
logger.Trace("ExampleLogger_Trace", watermill.LogFields{"test_field": 1})
Output:

{"level":"debug","msg":"ExampleLogger_Trace","test_field":1}

func (*Logger) With

With returns new LoggerAdapter with passed fields.

Jump to

Keyboard shortcuts

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