logex

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Custom Writer use SetOutput Custom Level use SetLogLevel handle log fatal use SetCancel

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

Debug is equivalent to Print() for DEBUG-level log.

func Debugf

func Debugf(format string, v ...interface{})

Debugf is equivalent to Printf() for DEBUG-level log.

func Error

func Error(v ...interface{})

Error is equivalent to Print() for Error-level log.

func Errorf

func Errorf(format string, v ...interface{})

Errorf is equivalent to Printf() for Error-level log.

func Fatal

func Fatal(v ...interface{})

Fatal is equivalent to Print() for FATAL-level log.

func Fatalf

func Fatalf(format string, v ...interface{})

Fatalf is equivalent to Printf() for FATAL-level log.

func Format added in v1.0.0

func Format(reqId string, moduleName string, v ...interface{}) ([]byte, error)

按照项目规范格式化代码

func Info

func Info(v ...interface{})

Info is equivalent to Print() for Info-level log.

func Infof

func Infof(format string, v ...interface{})

Infof is equivalent to Printf() for Info-level log.

func New added in v1.0.0

func New(level Level, out, errOut *log.Logger) *loggerIns

func SetCancel

func SetCancel(fn context.CancelFunc)

When Log write failed, it will call cancel. context.Context should be Done. others goroutine should finish their jobs and exit safety.

func SetLogLevel

func SetLogLevel(level Level)

func SetName added in v1.0.0

func SetName(n string)

func SetOutput

func SetOutput(out, err *log.Logger)

func Stats added in v1.1.1

func Stats(v ...interface{})

Fatalf is equivalent to Printf() for FATAL-level log.

func Statsf added in v1.1.1

func Statsf(format string, v ...interface{})

Fatalf is equivalent to Printf() for FATAL-level log.

func Warning

func Warning(v ...interface{})

Waring is equivalent to Print() for WARING-level log.

func Warningf

func Warningf(format string, v ...interface{})

Warningf is equivalent to Printf() for WARNING-level log.

func WrapIris added in v1.0.0

func WrapIris(app *iris.Application, projectName string)

Types

type Formatter added in v1.0.0

type Formatter func(v ...interface{}) ([]byte, error)

type Level

type Level uint
const (
	LNone Level = iota
	LStatistics
	LFatal
	LError
	LWarning
	LInfo
	LDebug
	LMax
)

func (Level) String added in v1.0.0

func (l Level) String() string

type Logger added in v1.0.0

type Logger interface {
	Statsf(format string, v ...interface{})
	Stats(v ...interface{})

	Fatalf(format string, v ...interface{})

	// Fatal is equivalent to Print() for FATAL-level log.
	Fatal(v ...interface{})

	// Errorf is equivalent to Printf() for Error-level log.
	Errorf(format string, v ...interface{})

	// Error is equivalent to Print() for Error-level log.
	Error(v ...interface{})

	// Warningf is equivalent to Printf() for WARNING-level log.
	Warningf(format string, v ...interface{})
	// Waring is equivalent to Print() for WARING-level log.
	Warning(v ...interface{})

	// Infof is equivalent to Printf() for Info-level log.
	Infof(format string, v ...interface{})

	// Info is equivalent to Print() for Info-level log.
	Info(v ...interface{})

	// Debugf is equivalent to Printf() for DEBUG-level log.
	Debugf(format string, v ...interface{})

	// Debug is equivalent to Print() for DEBUG-level log.
	Debug(v ...interface{})
}

func Wrap added in v1.0.0

func Wrap(reqId string, moduleName string) Logger

type UniversalLog added in v1.0.0

type UniversalLog struct {
	ReqId      string      `json:"req_id"`
	ModuleName string      `json:"module"`
	Info       interface{} `json:"info,omitempty"`
}

Jump to

Keyboard shortcuts

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