logger

package
v0.0.0-...-101e1e6 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(opts ...Option) *myLogger

NewLogger is create a logger based by logrus implements Logger

Types

type Level

type Level int

Level is the Log Level

const (
	Debug Level = iota - 1
	Info
	Warn
	Error
	Fatal
)

func (Level) String

func (l Level) String() string

String is description the log leve name

type Logger

type Logger interface {
	// WithField will config a field with name and value
	// This method will return a new Logger
	WithField(name string, value interface{}) Logger

	// DebugF log anything at debug level
	DebugF(format string, args ...interface{})

	// InfoF log anything at info level
	InfoF(format string, args ...interface{})

	// WarnF log anything at warning level
	WarnF(format string, args ...interface{})

	// ErrorF log anything at error level
	ErrorF(format string, args ...interface{})

	// FatalF log anything at fatal level
	FatalF(format string, args ...interface{})

	// SetLevel is set the Logger log level
	SetLevel(level Level)
}

Logger defined Logger for log anything

type Option

type Option func(options *Options)

Option used to change Options by closure

func WithJsonFormat

func WithJsonFormat(useJsonFormat bool) Option

WithJsonFormat is config whether to use json format log

func WithLevel

func WithLevel(level Level) Option

WithLevel is set the log level

func WithWriter

func WithWriter(writer io.Writer) Option

WithWriter is set the log writer

type Options

type Options struct {
	Writer     io.Writer
	Level      Level
	JsonFormat bool
}

Options used to config the log

Jump to

Keyboard shortcuts

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