logger

package module
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 4 Imported by: 0

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 l "github.com/surfe/logger"

...

fields := []any{l.UserKey, "abc@xyz.com"}
l.Log().Err(err).With(ctx, 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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Log

func Log() logi.Logger

Log is the getter for global `logger` variable

func Use

func Use(l logi.Logger) *wLogger

Use initiates a wLogger by wrapping provided Logger instance, and sets global logger variable

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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