leafLogrus

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: 7 Imported by: 10

README

Leaf Logger - Logrus

logging

Wrapping sirupsen logrus 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/logrus"
    ...
)

To Initialize logger:

var logger = leafLogrus.New() 

or pass the logger config

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

To logging:

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

output:

INFO[0000] [=Trace-ID=] Hello World                      attributes="map[data:test]" mandatory="map[authorization:map[api_key: service_id: token:***] device:map[app_version: brand: device_id: family: model:] device_type:map[] ip_addresses:[] operating_system:map[family: major: minor: name: patch: patch_minor: version:] trace_id:=Trace-ID= user:map[email:email id:1 is_login:true] user_agent:map[family: major: minor: patch: value:]]" message="[=Trace-ID=] Hello World" timestamp="2022-02-23T15:24:08+07:00"

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 Formatter

type Formatter string
const (
	JSONFormatter Formatter = "JSON"
	TextFormatter Formatter = "TEXT"
)

func GetLoggerFormatter

func GetLoggerFormatter(formatter string) (Formatter, error)

type Option

type Option interface {
	Apply(o *options)
}

func WithFormatter

func WithFormatter(formatter Formatter) Option

func WithLevel

func WithLevel(lvl log.Lvl) Option

func WithLogFilePath

func WithLogFilePath(path string) Option

func WithMasking

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

func WithPrefix

func WithPrefix(prefix string) Option

Jump to

Keyboard shortcuts

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