log

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package log providers a logger with level (DEBUG, INFO, WARN, ERROR, FATAL, PANIC).

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultLogger represents the default logger.
	DefaultLogger = NewLogger(os.Stdout, "")
)

Functions

func Debug

func Debug(args ...interface{})

Debug is short for DefaultLogger.Debug.

func Debugf

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

Debugf is short for DefaultLogger.Debugf.

func Debugln

func Debugln(args ...interface{})

Debugln is short for DefaultLogger.Debugln.

func Error

func Error(args ...interface{})

Error is short for DefaultLogger.Error.

func Errorf

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

Errorf is short for DefaultLogger.Errorf.

func Errorln

func Errorln(args ...interface{})

Errorln is short for DefaultLogger.Errorln.

func Fatal

func Fatal(args ...interface{})

Fatal is short for DefaultLogger.Fatal.

func Fatalf

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

Fatalf is short for DefaultLogger.Fatalf.

func Fatalln

func Fatalln(args ...interface{})

Fatalln is short for DefaultLogger.Fatalln.

func Info

func Info(args ...interface{})

Info is short for DefaultLogger.Info.

func Infof

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

Infof is short for DefaultLogger.Infof.

func Infoln

func Infoln(args ...interface{})

Infoln is short for DefaultLogger.Infoln.

func Panic

func Panic(args ...interface{})

Panic is short for DefaultLogger.Panic.

func Panicf

func Panicf(fmt string, args ...interface{})

Panicf is short for DefaultLogger.Panicf.

func Panicln

func Panicln(args ...interface{})

Panicln is short for DefaultLogger.Panicln.

func Warn

func Warn(args ...interface{})

Warn is short for DefaultLogger.Warn.

func Warnf

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

Warnf is short for DefaultLogger.Warnf.

func Warnln

func Warnln(args ...interface{})

Warnln is short for DefaultLogger.Warnln.

Types

type Level

type Level byte

Level represents the level of log.

const (
	// LevelOff represents turn off all logs.
	LevelOff Level = iota
	// LevelPanic turns on: panic logs only.
	LevelPanic
	// LevelFatal turns on: panic & fatal logs.
	LevelFatal
	// LevelError turns on: panic & fatal & error logs.
	LevelError
	// LevelWarn turns on: panic & fatal & error & warn logs.
	LevelWarn
	// LevelInfo turns on: panic & fatal & error & warn & info logs.
	LevelInfo
	// LevelDebug turns on: panic & fatal & error & warn & info & debug logs.
	LevelDebug
	// LevelAll turns on all logs.
	LevelAll
)

type Logger

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

Logger represents a level logger.

func NewLogger

func NewLogger(out io.Writer, prefix string) *Logger

NewLogger returns a new level logger.

func (*Logger) Debug

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

Debug outputs debug log. Arguments are handled in the manner of fmt.Print.

func (*Logger) Debugf

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

Debugf outputs debug log. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Debugln

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

Debugln outputs debug log. Arguments are handled in the manner of fmt.Println.

func (*Logger) Error

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

Error outputs error log. Arguments are handled in the manner of fmt.Print.

func (*Logger) Errorf

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

Errorf outputs error log. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Errorln

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

Errorln outputs error log. Arguments are handled in the manner of fmt.Println.

func (*Logger) Fatal

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

Fatal outputs fatal log followed by a call to os.Exit(1). Arguments are handled in the manner of fmt.Print.

func (*Logger) Fatalf

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

Fatalf outputs fatal log followed by a call to os.Exit(1). Arguments are handled in the manner of fmt.Printf.

func (*Logger) Fatalln

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

Fatalln outputs fatal log followed by a call to os.Exit(1). Arguments are handled in the manner of fmt.Println.

func (*Logger) Info

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

Info outputs info log. Arguments are handled in the manner of fmt.Print.

func (*Logger) Infof

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

Infof outputs info log. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Infoln

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

Infoln outputs info log. Arguments are handled in the manner of fmt.Println.

func (*Logger) Level

func (l *Logger) Level() Level

Level returns the level of logger.

func (*Logger) Panic

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

Panic outputs panic log followed by a call to panic. Arguments are handled in the manner of fmt.Print.

func (*Logger) Panicf

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

Panicf outputs panic log followed by a call to panic. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Panicln

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

Panicln outputs panic log followed by a call to panic. Arguments are handled in the manner of fmt.Println.

func (*Logger) Prefix

func (l *Logger) Prefix() string

Prefix returns the prefix of logger.

func (*Logger) SetLevel

func (l *Logger) SetLevel(v Level)

SetLevel sets the level of logger.

func (*Logger) SetOutput

func (l *Logger) SetOutput(w io.Writer)

SetOutput sets the output of logger.

func (*Logger) SetPrefix

func (l *Logger) SetPrefix(v string)

SetPrefix sets the prefix of logger.

func (*Logger) Warn

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

Warn outputs warn log. Arguments are handled in the manner of fmt.Print.

func (*Logger) Warnf

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

Warnf outputs warn log. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Warnln

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

Warnln outputs warn log. Arguments are handled in the manner of fmt.Println.

Jump to

Keyboard shortcuts

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