slogwatermill

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 3 Imported by: 0

README

slog: watermill logger adapter

Watermill logger adapter for slog logger

Go Version GoDoc Build Status Go report Coverage License

Watermill LoggerAdapter implementation to log using slog.

See also:

🚀 Install

go get github.com/denisss025/slog-watermill

Compatibility: go >= 1.21

No breaking changes will be made to exported APIs before v2.0.0.

💡 Usage

Minimal

Using custom time formatters

Using custom logger sub-group

Adding custom attributes

JSON output

🤝 Contributing

Don't hesitate ;)

# Install some dev dependencies
make tools

# Run tests
make test
# or
make watch-test

👤 Contributors

Contributors

💫 Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2023 Denis Novikov.

This project is MIT licensed.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter implements watermill.LoggerAdapter.

func New

func New(logger *slog.Logger) *Adapter

New creates an instance of Adapter with debug log level and a watermill group.

func NewWithConfig

func NewWithConfig(logger *slog.Logger, config Config) *Adapter

NewWithConfig creates an instance with a given log level and a watermill group.

func (Adapter) Debug

func (a Adapter) Debug(msg string, fields watermill.LogFields)

Debug logs some debug information.

func (Adapter) Error

func (a Adapter) Error(msg string, err error, fields watermill.LogFields)

Error logs an error.

func (Adapter) Info

func (a Adapter) Info(msg string, fields watermill.LogFields)

Info logs some useful information.

func (Adapter) Trace

func (a Adapter) Trace(msg string, fields watermill.LogFields)

Trace logs trace information.

func (Adapter) With

With creates a new instance with some extra fields.

type Config

type Config struct {
	// Log level (default: LevelDebug).
	Level Level
}

Adapter config.

type Level

type Level int

A Level is the importance or severity of a log event. The higher the level, the more important or severe the event.

const (
	LevelTrace Level = -8
	LevelDebug Level = -4
	LevelInfo  Level = 0
	LevelWarn  Level = 4
	LevelError Level = 8
)

Jump to

Keyboard shortcuts

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