logy

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

README

github.com/gkzy/gku/lib/logy

Documentation

Overview

like https://gitea.com/lunny/log but made some adjustments

Index

Constants

View Source
const (
	Ldebug = iota
	Linfo
	Lwarn
	Lerror
	Lpanic
	Lfatal
	Lnone
)
View Source
const (
	ForeBlack  = iota + 30 //30
	ForeRed                //31
	ForeGreen              //32
	ForeYellow             //33
	ForeBlue               //34
	ForePurple             //35
	ForeCyan               //36
	ForeWhite              //37
)
View Source
const (
	BackBlack  = iota + 40 //40
	BackRed                //41
	BackGreen              //42
	BackYellow             //43
	BackBlue               //44
	BackPurple             //45
	BackCyan               //46
	BackWhite              //47
)
View Source
const (
	Lall = iota
)

Variables

View Source
var (
	Std = New(os.Stdout, "", logDefaultLevel())
)

Functions

func Debug

func Debug(v ...interface{})

Debug

func Debugf

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

Debugf

func Error

func Error(v ...interface{})

Error

func Errorf

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

Errorf

func Fatal

func Fatal(v ...interface{})

Fatal

func Fatalf

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

Fatalf

func Info

func Info(v ...interface{})

func Infof

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

Infof

func Panic

func Panic(v ...interface{})

Panic

func Panicf

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

Panicf

func Print

func Print(v ...interface{})

Print

func Printf

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

Printf

func Println

func Println(v ...interface{})

Println

func SetColors

func SetColors(cls []int)

MUST called before all logs

func SetFileFormat

func SetFileFormat(t ByType, format string)

SetFileFormat 设置文件格式

func SetLevels

func SetLevels(lvs []string)

SetLevels MUST called before all logs

func SetOutPut

func SetOutPut(out io.Writer)

func Warn

func Warn(v ...interface{})

Warn

func Warnf

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

Warnf

Types

type ByType

type ByType int
const (
	Day ByType = iota
	Hour
	Month
)

func (ByType) GetFileFormat

func (b ByType) GetFileFormat() string

GetFileFormat 获取格式

type FileInfo

type FileInfo struct {
	Name    string
	ModTime time.Time
	Size    int64
}

FileInfo

type FileOptions

type FileOptions struct {
	Dir    string         //日志目录
	ByType ByType         //按天/小时/月?
	Loc    *time.Location //时间
	MaxDay int            //最大留存天数
}

FileOptions 写文件选项

type Files

type Files struct {
	FileOptions
	// contains filtered or unexported fields
}

func NewFileWriter

func NewFileWriter(opts ...FileOptions) *Files

NewFileWriter 设置写文件参数

	w:=logy.NewFileWriter(logy.FileOptions{
		ByType:log.Day,
		Dir:"./logs",
		MaxDay:6,
	})
 logy.Std.SetOutPut(w)

func (*Files) Close

func (f *Files) Close()

func (*Files) Write

func (f *Files) Write(bs []byte) (int, error)

type Logger

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

Logger

func New

func New(out io.Writer, prefix string, flag int) *Logger

New return *Logger

func (*Logger) Debug

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

Debug

func (*Logger) Debugf

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

Debugf

func (*Logger) Error

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

Error

func (*Logger) Errorf

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

Errorf

func (*Logger) Info

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

Info

func (*Logger) Infof

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

Infof

func (*Logger) Panic

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

Panic

func (*Logger) Panicf

func (l *Logger) Panicf(format string, v ...interface{})

Panicf

func (*Logger) Print

func (l *Logger) Print(v ...interface{})

Print

func (*Logger) Printf

func (l *Logger) Printf(format string, v ...interface{})

Printf

func (*Logger) Println

func (l *Logger) Println(v ...interface{})

Println

func (*Logger) SetOutPut

func (l *Logger) SetOutPut(out io.Writer)

func (*Logger) Warn

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

Warn

func (*Logger) Warnf

func (l *Logger) Warnf(format string, v ...interface{})

Warnf

Jump to

Keyboard shortcuts

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