Categorygithub.com/surfe/logger/v2
modulepackage
2.0.1
Repository: https://github.com/surfe/logger.git
Documentation: pkg.go.dev

# README

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, "[email protected]"}
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

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

Log is the getter for global `logger` variable.
Use initiates a wLogger by wrapping provided Logger instance, and sets global logger variable.