leafLogger

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: 8 Imported by: 33

README

Leaf Logger

Logger Interface

Logger interface for support leaf framework

Logger interface {
    Info(message Message)
    Warn(message Message)
    Error(message Message)
    Debug(message Message)
    StandardLogger() StandardLogger
}

StandardLogger interface {
    Output() io.Writer
    SetOutput(w io.Writer)
    Prefix() string
    SetPrefix(prefix string)
    Level() log.Lvl
    SetLevel(v log.Lvl)
    SetHeader(header string)
    Print(i ...interface{})
    Println(i ...interface{})
    Printf(format string, i ...interface{})
    Printj(j log.JSON)
    Debug(i ...interface{})
    Debugf(format string, i ...interface{})
    Debugj(j log.JSON)
    Info(i ...interface{})
    Infof(format string, i ...interface{})
    Infoj(j log.JSON)
    Warn(i ...interface{})
    Warnf(format string, i ...interface{})
    Warnj(j log.JSON)
    Error(i ...interface{})
    Errorf(format string, i ...interface{})
    Errorj(j log.JSON)
    Fatal(i ...interface{})
    Fatalf(format string, i ...interface{})
    Fatalj(j log.JSON)
    Panic(i ...interface{})
    Panicf(format string, i ...interface{})
    Panicj(j log.JSON)
    Instance() interface{}
    Log(msg string)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLoggerLevel

func GetLoggerLevel(level string) log.Lvl

Types

type Logger

type Logger interface {
	Info(message Message)
	Warn(message Message)
	Error(message Message)
	Debug(message Message)
	StandardLogger() StandardLogger
}

type Masked

type Masked struct {
	Key      string
	Aliasing string
	Pattern  string
	Skipper  Skipper
}

if Aliasing is filled will replace all value with Aliasing value Fill StartIdx and EndIdx with 0 to masked all value with Pattern example: { Key: Value } Aliasing: ***, Pattern: *, StartIdx: 0, EndIdx: 0 -> { Key: *** } Pattern: *, Skipper.First: 0, Skipper.Last: 0 -> { Key: ***** } Pattern: -, Skipper.First: 1, Skipper.Last: 2 -> { Key: V--ue } Pattern: *, Skipper.First: 3, Skipper.Last: 3 -> { Key: Value }

type MaskedEncoder

type MaskedEncoder map[string]Masked

func (MaskedEncoder) Encode

func (masked MaskedEncoder) Encode(key string, data interface{}) interface{}

type Message

type Message map[string]interface{}

func BuildMessage

func BuildMessage(ctx context.Context, msg string, opts ...MessageOption) Message

func (Message) MarshalJSON

func (msg Message) MarshalJSON() ([]byte, error)

func (Message) MarshalText

func (msg Message) MarshalText() ([]byte, error)

func (Message) String

func (msg Message) String() string

type MessageOption

type MessageOption interface {
	Apply(o *messageOptions)
}

func WithAttr

func WithAttr(key string, value interface{}) MessageOption

WithAttr function to add attributes to messages

func WithMasking

func WithMasking(key string, masked Masked) MessageOption

WithMasking function to add masking specific key to messages

type Skipper

type Skipper struct {
	First int
	Last  int
}

type StandardLogger

type StandardLogger interface {
	Output() io.Writer
	SetOutput(w io.Writer)
	Prefix() string
	SetPrefix(prefix string)
	Level() log.Lvl
	SetLevel(v log.Lvl)
	SetHeader(header string)
	Print(i ...interface{})
	Println(i ...interface{})
	Printf(format string, i ...interface{})
	Printj(j log.JSON)
	Debug(i ...interface{})
	Debugf(format string, i ...interface{})
	Debugj(j log.JSON)
	Info(i ...interface{})
	Infof(format string, i ...interface{})
	Infoj(j log.JSON)
	Warn(i ...interface{})
	Warnf(format string, i ...interface{})
	Warnj(j log.JSON)
	Error(i ...interface{})
	Errorf(format string, i ...interface{})
	Errorj(j log.JSON)
	Fatal(i ...interface{})
	Fatalf(format string, i ...interface{})
	Fatalj(j log.JSON)
	Panic(i ...interface{})
	Panicf(format string, i ...interface{})
	Panicj(j log.JSON)
	Instance() interface{}
	Log(msg string)
}

Jump to

Keyboard shortcuts

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