leafZap

package module
v0.0.0-...-0829b1e Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT Imports: 5 Imported by: 1

README

Leaf Logger - Zap

logging

Wrapping uber zap logging library to follow interface leaf framework

Usage

Import the package

import (
    ...
    "github.com/paulusrobin/leaf-utilities/logger/logger"
    "github.com/paulusrobin/leaf-utilities/logger/integrations/zap"
    ...
)

To Initialize logger:

var logger = leafZap.New() 

or pass the logger config

var logger = leafZap.New(...leafZap.Option) 

To logging:

logger.Info(leafLogger.BuildMessage(ctx,
    "Hello World",
    taniLogger.WithAttr("data", "test"),
))

output:

{"level":"info","ts":"2022-02-23T15:02:33+07:00","caller":"zap/logger.go:19","msg":"[=Trace-ID=] Hello World","message":"[=Trace-ID=] Hello World","attributes":{"data":"test"},"timestamp":"2022-02-23T15:02:33+07:00","mandatory":{"authorization":{"api_key":"","service_id":"","token":"***"},"device":{"app_version":"","brand":"","device_id":"","family":"","model":""},"device_type":{},"ip_addresses":null,"operating_system":{"family":"","major":"","minor":"","name":"","patch":"","patch_minor":"","version":""},"trace_id":"=Trace-ID=","user":{"email":"email","id":1,"is_login":true},"user_agent":{"family":"","major":"","minor":"","patch":"","value":""}}}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLog

func DefaultLog() leafLogger.Logger

func New

func New(opts ...Option) (leafLogger.Logger, error)

Types

type Option

type Option interface {
	Apply(o *options)
}

func WithLevel

func WithLevel(lvl log.Lvl) Option

func WithMasking

func WithMasking(key string, masked leafLogger.Masked) Option

func WithPrefix

func WithPrefix(prefix string) Option

func WithTimeEncoder

func WithTimeEncoder(timeEncoder zapcore.TimeEncoder) Option

func WithZapOption

func WithZapOption(opt zap.Option) Option

Jump to

Keyboard shortcuts

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