logger

package module
v2.1.6-gamma Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: MIT Imports: 5 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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, "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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Log

func Log(ctx context.Context) 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