logger

package
v0.0.0-...-2c4df64 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2018 License: LGPL-3.0 Imports: 12 Imported by: 0

README

logger

a std logger wapper package with rotate file support

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(bytes uint64) string

func Debugf

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

func Debugln

func Debugln(args ...interface{})

func Errorf

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

func Errorln

func Errorln(args ...interface{})

func Fatalf

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

func Fatalln

func Fatalln(args ...interface{})

func Infof

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

func Infoln

func Infoln(args ...interface{})

func Init

func Init(level LogLevel, writer ...io.Writer)

func MustToBytes

func MustToBytes(s string) uint64

func NewWriter

func NewWriter(w ...io.Writer) io.Writer

func Printf

func Printf(lvl LogLevel, format string, args ...interface{})

func Println

func Println(lvl LogLevel, args ...interface{})

func ToBytes

func ToBytes(s string) (uint64, error)

func Tracef

func Tracef(format string, args ...interface{})

func Traceln

func Traceln(args ...interface{})

func Warnf

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

func Warnln

func Warnln(args ...interface{})

Types

type ByteSize

type ByteSize uint64

<editor-fold desc="ByteSize">

const (
	//_           = iota // ignore first value by assigning to blank identifier
	B ByteSize = 1 << (10 * iota)
	KB
	MB
	GB
	TB
	PB
	EB
)

func (ByteSize) Float64

func (s ByteSize) Float64() float64

func (ByteSize) Int64

func (s ByteSize) Int64() int64

func (ByteSize) String

func (s ByteSize) String() string

func (ByteSize) Uint64

func (s ByteSize) Uint64() uint64

type ILogger

type ILogger interface {
	CurrentLevel() int
	Fatalln(args ...interface{})
	Fatalf(format string, args ...interface{})
	Errorln(args ...interface{})
	Errorf(format string, args ...interface{})
	Warnln(args ...interface{})
	Warnf(format string, args ...interface{})
	Infoln(args ...interface{})
	Infof(format string, args ...interface{})
	Debugln(args ...interface{})
	Debugf(format string, args ...interface{})
	Traceln(args ...interface{})
	Tracef(format string, args ...interface{})
}

type LogLevel

type LogLevel int

<editor-fold desc="logger">

const (
	TRACE LogLevel = iota
	DEBUG
	INFO
	WARN
	ERROR
	FATAL
)

func ParseLogLevel

func ParseLogLevel(i int) LogLevel

func (LogLevel) String

func (l LogLevel) String() string

type Logger

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

func GetLogger

func GetLogger() *Logger

func NewLogger

func NewLogger(o io.Writer, level LogLevel) *Logger

func (Logger) CurrentLevel

func (l Logger) CurrentLevel() int

func (Logger) Debugf

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

func (Logger) Debugln

func (l Logger) Debugln(args ...interface{})

func (Logger) Errorf

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

func (Logger) Errorln

func (l Logger) Errorln(args ...interface{})

func (Logger) Fatalf

func (l Logger) Fatalf(format string, args ...interface{})

func (Logger) Fatalln

func (l Logger) Fatalln(args ...interface{})

func (Logger) Infof

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

func (Logger) Infoln

func (l Logger) Infoln(args ...interface{})

func (Logger) Printf

func (l Logger) Printf(lvl LogLevel, format string, args ...interface{})

func (Logger) Println

func (l Logger) Println(lvl LogLevel, args ...interface{})

func (Logger) Tracef

func (l Logger) Tracef(format string, args ...interface{})

func (Logger) Traceln

func (l Logger) Traceln(args ...interface{})

func (Logger) Warnf

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

func (Logger) Warnln

func (l Logger) Warnln(args ...interface{})

type LoggerWriter

type LoggerWriter struct {
	Writers []io.Writer
}

func (*LoggerWriter) Write

func (w *LoggerWriter) Write(output []byte) (int, error)

type RotateWriter

type RotateWriter struct {
	// contains filtered or unexported fields
}

<editor-fold desc="RotateWriter">

func NewRotateWriter

func NewRotateWriter(filename string, size uint64, rotateDelay time.Duration) (*RotateWriter, context.CancelFunc)

Make a new RotateWriter. Return nil if error occurs during setup.

func (*RotateWriter) Rotate

func (w *RotateWriter) Rotate() (err error)

Perform the actual act of rotating and reopening file.

func (*RotateWriter) Write

func (w *RotateWriter) Write(output []byte) (int, error)

Write satisfies the io.Writer interface.

Jump to

Keyboard shortcuts

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