logger

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2020 License: Apache-2.0 Imports: 8 Imported by: 23

README

logger

如何使用

導入
 go get -u --insecure github.com/codingXiang/go-logger
使用

創建實例

logger.Log = logger.NewLogger(logger.Logger{
	Level: "debug",
	Format: "json",
})
//Debug
logger.Log.Debug("test")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPathSymbol added in v1.0.2

func GetPathSymbol() string

Types

type LogLevel

type LogLevel string

log 等級類別

func (LogLevel) GetLevel

func (level LogLevel) GetLevel() logrus.Level

func (LogLevel) String

func (level LogLevel) String() string

type Logger

type Logger struct {
	Level  string `yaml:"level"`  //等級(有 debug、info、error、fatal 與 panic)
	Format string `yaml:"format"` //格式(有 json 或 text)
	// contains filtered or unexported fields
}

log 物件

func InterfaceToLogger

func InterfaceToLogger(data interface{}) Logger

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

func (*Logger) GetFormatter

func (l *Logger) GetFormatter() string

func (*Logger) GetLevel

func (l *Logger) GetLevel() string

func (*Logger) GetLogger

func (l *Logger) GetLogger() *logrus.Logger

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

func (*Logger) Panic

func (l *Logger) Panic(args ...interface{})

func (*Logger) SetFormatter

func (l *Logger) SetFormatter(format string)

func (*Logger) SetLevel

func (l *Logger) SetLevel(level string)

func (*Logger) SetOutput added in v1.0.1

func (l *Logger) SetOutput(config *viper.Viper)

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

type LoggerInterface

type LoggerInterface interface {
	//GetLogger : 取得 Logger
	GetLogger() *logrus.Logger
	//設定 log 等級
	SetLevel(level string)
	//取得 log 等級
	GetLevel() string
	//設定 output
	SetOutput(config *viper.Viper)
	//取得 log 輸出格式
	GetFormatter() string
	//設定 log 輸出格式
	SetFormatter(format string)
	// 輸出 debug 等級 log
	Debug(args ...interface{})
	// 輸出 info 等級 log
	Info(args ...interface{})
	// 輸出 warn 等級 log
	Warn(args ...interface{})
	// 輸出 error 等級 log
	Error(args ...interface{})
	// 輸出 fatal 等級 log
	Fatal(args ...interface{})
	// 輸出 panic 等級 log
	Panic(args ...interface{})
}

log 介面

var (
	Log LoggerInterface
)

func NewLogger

func NewLogger(setting Logger) LoggerInterface

func NewLoggerWithConfiger added in v1.0.1

func NewLoggerWithConfiger(config *viper.Viper) LoggerInterface

Jump to

Keyboard shortcuts

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