Skip to content
/ logger Public

Logging library wrapper with `Echo` and discard rules support.

License

Notifications You must be signed in to change notification settings

surfe/logger

Repository files navigation

Logger

Logging library wrapper with Echo.

Install

go get -u github.com/surfe/logger

Usage

Initialization

Initiate a Zap logger;

zapLogger, err := zap.Init()
if err != nil {
	log.Panic(err)
}
defer zapLogger.Sync()

Use the logger;

l := logger.Use(zapLogger)

Logging

Error with a message and extra fields;

import "github.com/surfe/logger"

...

fields := []any{l.UserKey, "abc@xyz.com"}
logger.Log(ctx).Err(err).With(fields...).Error("Add Contact (SF)")

Echo Middleware

e.Use(l.EchoMiddleware())

Development

You can use go work to develop this module:

go work init .
go work use ../logger