ilog

package
v0.0.0-...-5fdeb2f Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: LGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddWriter

func AddWriter(lw LogWriter) error

AddWriter adds writer to the global defaultLogger.

func AsyncWrite

func AsyncWrite()

AsyncWrite sets logger's syncWrite to false.

func Debug

func Debug(v ...interface{})

Debug generates a debug-level log.

func Debugf

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

Debugf generates a debug-level log.

func Debugln

func Debugln(v ...interface{})

Debugln generates a debug-level log.

func Error

func Error(v ...interface{})

Error generates a error-level log.

func Errorf

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

Errorf generates a error-level log.

func Errorln

func Errorln(v ...interface{})

Errorln generates a error-level log.

func Fatal

func Fatal(v ...interface{})

Fatal generates a fatal-level log and exits the program.

func Fatalf

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

Fatalf generates a fatal-level log and exits the program.

func Fatalln

func Fatalln(v ...interface{})

Fatalln generates a fatal-level log and exits the program.

func Flush

func Flush()

Flush flushes the global defaultLogger.

func HideLocation

func HideLocation()

HideLocation sets logger's showLocation to false.

func Info

func Info(v ...interface{})

Info generates a info-level log.

func Infof

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

Infof generates a info-level log.

func Infoln

func Infoln(v ...interface{})

Infoln generates a info-level log.

func InitLogger

func InitLogger(logger *Logger)

InitLogger inits the global defaultLogger.

func SetCallDepth

func SetCallDepth(d int)

SetCallDepth sets the global defaultLogger's call depth.

func SetLevel

func SetLevel(l Level)

SetLevel sets the defaultLogger's level.

func Start

func Start()

Start starts the global defaultLogger.

func Stop

func Stop()

Stop stops the global defaultLogger.

func Warn

func Warn(v ...interface{})

Warn generates a warn-level log.

func Warnf

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

Warnf generates a warn-level log.

func Warnln

func Warnln(v ...interface{})

Warnln generates a warn-level log.

Types

type BufPool

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

BufPool wraps sync.Pool to make it handy.

func NewBufPool

func NewBufPool() *BufPool

NewBufPool returns a new instance of BufPool.

func (*BufPool) Get

func (bp *BufPool) Get() *bytes.Buffer

Get returns a bytes.Buffer from bufPool.

func (*BufPool) Release

func (bp *BufPool) Release(buf *bytes.Buffer)

Release puts bytes.Buffer back to bufPool.

type ConsoleWriter

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

ConsoleWriter is responsible for writing log to console.

func NewConsoleWriter

func NewConsoleWriter() *ConsoleWriter

NewConsoleWriter returns a new instance of ConsoleWriter.

func (*ConsoleWriter) Close

func (cw *ConsoleWriter) Close() error

Close closes the writer.

func (*ConsoleWriter) Flush

func (cw *ConsoleWriter) Flush() error

Flush flushes.

func (*ConsoleWriter) GetLevel

func (cw *ConsoleWriter) GetLevel() Level

GetLevel returns the log level.

func (*ConsoleWriter) Init

func (cw *ConsoleWriter) Init() error

Init inits ConsoleWriter.

func (*ConsoleWriter) SetLevel

func (cw *ConsoleWriter) SetLevel(l Level)

SetLevel sets the log level.

func (*ConsoleWriter) Write

func (cw *ConsoleWriter) Write(msg string, level Level) error

Write writes message to the console.

type FileWriter

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

FileWriter is responsible for writing log to file.

func NewFileWriter

func NewFileWriter(filepath string) *FileWriter

NewFileWriter returns a new instance of NewFileWriter.

func (*FileWriter) Close

func (fw *FileWriter) Close() error

Close closes the writer.

func (*FileWriter) Flush

func (fw *FileWriter) Flush() error

Flush flushes.

func (*FileWriter) GetLevel

func (fw *FileWriter) GetLevel() Level

GetLevel returns the log level.

func (*FileWriter) Init

func (fw *FileWriter) Init() error

Init inits NewFileWriter.

func (*FileWriter) SetLevel

func (fw *FileWriter) SetLevel(l Level)

SetLevel sets the log level.

func (*FileWriter) Write

func (fw *FileWriter) Write(msg string, level Level) error

Write writes message to the console.

type Level

type Level int

Level is the log level.

const (
	LevelDebug Level = iota
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
)

log level enum.

func GetLevel

func GetLevel() (l Level)

GetLevel gets the defaultLogger's level.

func NewLevel

func NewLevel(l string) Level

NewLevel will return a new level by name

type LogWriter

type LogWriter interface {
	Init() error
	SetLevel(Level)
	GetLevel() Level
	Write(msg string, level Level) error
	Flush() error
	Close() error
}

LogWriter defines writer's API.

type Logger

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

Logger is the core struct of ilog package. It packs message and sends it to the writer.

func DefaultLogger

func DefaultLogger() *Logger

DefaultLogger returns the global defaultLogger.

func New

func New() *Logger

New returns a default Logger instance.

func NewConsoleLogger

func NewConsoleLogger() *Logger

NewConsoleLogger returns a Logger instance with a console writer.

func (*Logger) AddWriter

func (logger *Logger) AddWriter(writer LogWriter) error

AddWriter adds a writer to logger.

func (*Logger) AsyncWrite

func (logger *Logger) AsyncWrite()

AsyncWrite sets logger's syncWrite to false.

func (*Logger) Debug

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

Debug generates a debug-level log.

func (*Logger) Debugf

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

Debugf generates a debug-level log.

func (*Logger) Debugln

func (logger *Logger) Debugln(v ...interface{})

Debugln generates a debug-level log.

func (*Logger) Error

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

Error generates a error-level log.

func (*Logger) Errorf

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

Errorf generates a error-level log.

func (*Logger) Errorln

func (logger *Logger) Errorln(v ...interface{})

Errorln generates a error-level log.

func (*Logger) Fatal

func (logger *Logger) Fatal(v ...interface{})

Fatal generates a fatal-level log and exits the program.

func (*Logger) Fatalf

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

Fatalf generates a fatal-level log and exits the program.

func (*Logger) Fatalln

func (logger *Logger) Fatalln(v ...interface{})

Fatalln generates a fatal-level log and exits the program.

func (*Logger) Flush

func (logger *Logger) Flush()

Flush flushes the logger.

func (*Logger) GetLevel

func (logger *Logger) GetLevel() (l Level)

GetLevel returns the lowestLevel

func (*Logger) HideLocation

func (logger *Logger) HideLocation()

HideLocation sets logger's showLocation to false.

func (*Logger) Info

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

Info generates a info-level log.

func (*Logger) Infof

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

Infof generates a info-level log.

func (*Logger) Infoln

func (logger *Logger) Infoln(v ...interface{})

Infoln generates a info-level log.

func (*Logger) SetCallDepth

func (logger *Logger) SetCallDepth(d int)

SetCallDepth sets the logger's call depth.

func (*Logger) SetLevel

func (logger *Logger) SetLevel(l Level)

SetLevel sets all the writers' level to l.

func (*Logger) Start

func (logger *Logger) Start()

Start starts the logger.

func (*Logger) Stop

func (logger *Logger) Stop()

Stop stops the logger.

func (*Logger) Warn

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

Warn generates a warn-level log.

func (*Logger) Warnf

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

Warnf generates a warn-level log.

func (*Logger) Warnln

func (logger *Logger) Warnln(v ...interface{})

Warnln generates a warn-level log.

Jump to

Keyboard shortcuts

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