logger

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package logger basic and simple logger for application, it base the go embed `log` package. it's able to control output by log level, level order `all<debug<info<warn<error<none`.

Example
lg := NewLogger(Config{})
lg.Debugf("it's a debug level message")
lg.Errorf("it's a error level message")
lg.Warnf("it's a warn level message")
lg.Errorf("it's a error level message")
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Log   *log.Logger
	Level string
	// driver list: stdout, file
	Driver string
	// when Driver is file it will ok
	OutputDir string
}

Config builder logging configure.

type Level

type Level int8
const (
	LogAll Level = iota
	LogDebug
	LogInfo
	LogWarn
	LogError
	LogNone
)

type Logger

type Logger struct {
	Level Level
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(cfg Config) *Logger

NewLogger build a simple logger user it.

func (Logger) Debugf

func (l Logger) Debugf(message string, args ...interface{})

func (Logger) Errorf

func (l Logger) Errorf(message string, args ...interface{})

func (Logger) Format

func (l Logger) Format(prefix, message string, args ...interface{})

func (Logger) Infof

func (l Logger) Infof(message string, args ...interface{})

func (Logger) Log

func (l Logger) Log() *log.Logger

Log get embed go lib log when you need the instance.

func (Logger) Warnf

func (l Logger) Warnf(message string, args ...interface{})

Jump to

Keyboard shortcuts

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