log

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Reset       = "\033[0m"
	Red         = "\033[31m"
	Green       = "\033[32m"
	Yellow      = "\033[33m"
	Blue        = "\033[34m"
	Magenta     = "\033[35m"
	Cyan        = "\033[36m"
	White       = "\033[37m"
	BlueBold    = "\033[34;1m"
	MagentaBold = "\033[35;1m"
	RedBold     = "\033[31;1m"
	YellowBold  = "\033[33;1m"
)

Colors

Variables

View Source
var (
	// Default log
	Default = New(log.New(os.Stdout, "\r\n", log.LstdFlags), Config{
		SlowThreshold: 200 * time.Millisecond,
		LogLevel:      LevelWarn,
		Colorful:      true,
	})
)

Functions

func FileWithLineNum

func FileWithLineNum() string

FileWithLineNum File line num

Types

type Config

type Config struct {
	SlowThreshold time.Duration
	Colorful      bool
	LogLevel      LogLevel
}

Config log config

type Interface

type Interface interface {
	LogMode(LogLevel) Interface
	Debug(string, ...interface{})
	D(string, ...interface{})
	Dump(args ...interface{})
	Printf(string, ...interface{})
	Info(string, ...interface{})
	Warn(string, ...interface{})
	Error(string, ...interface{})
	Trace(time.Time, func() (string, int64), error)
}

Interface logger interface

func New

func New(writer Writer, config Config) Interface

New new log interface

func NewLogger

func NewLogger(out io.Writer, level LogLevel) Interface

NewLogger New Logger engine

type LogLevel

type LogLevel int

LogLevel define

const (
	LevelSilent LogLevel = iota + 1
	LevelError
	LevelWarn
	LevelInfo
	LevelDebug
)

type Writer

type Writer interface {
	Printf(string, ...interface{})
}

Writer log writer interface

Jump to

Keyboard shortcuts

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