log

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2022 License: MIT Imports: 6 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package log adds log levels to the built in log package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

Debug calls Debug(v...) on the default Logger

func Debugf

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

Debugf calls Debugf(format, v...) on the default Logger

func Debugln

func Debugln(v ...interface{})

Debugln calls Debugln(v...) on the default Logger

func Error

func Error(v ...interface{})

Error calls Error(v...) on the default Logger

func Errorf

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

Errorf calls Errorf(format, v...) on the default Logger

func Errorln

func Errorln(v ...interface{})

Errorln calls Errorln(v...) on the default Logger

func Info

func Info(v ...interface{})

Info calls Info(v...) on the default Logger

func Infof

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

Infof calls Infof(format, v...) on the default Logger

func Infoln

func Infoln(v ...interface{})

Infoln calls Infoln(v...) on the default Logger

func JSON

func JSON(v interface{}) string

JSON returns v marshalled into JSON. If an error occurs, an error message is returned instead. It can be used to quickly add a JSON object into a log message.

func JSONIndent

func JSONIndent(v interface{}) string

JSONIndent returns v marshalled into JSON, with indentation. If an error occurs, an error message is returned instead. It can be used to quickly add a JSON object into a log message.

func SetLevel

func SetLevel(level Level)

SetLevel sets the loggin level of the default Logger

func Warn

func Warn(v ...interface{})

Warn calls Warn(v...) on the default Logger

func Warnf

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

Warnf calls Warnf(format, v...) on the default Logger

func Warnln

func Warnln(v ...interface{})

Warnln calls Warnln(v...) on the default Logger

Types

type Level

type Level uint8

Level is a log level

const (
	LevelDebug Level = iota
	LevelInfo
	LevelWarn
	LevelError
)

Available log levels

type Logger

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

A Logger wraps multiple loggers (one per log level). Individual loggers may be enabled or disabled depending on the current level (which can be set using the SetLevel function). Messages logged to a disabled level will be discarded.

func Default

func Default() *Logger

Default returns the default Logger instance

func New

func New(out io.Writer, level Level) *Logger

New returns a new Logger which outputs enabled levels to out. level allows to set the initial enabled level.

func (*Logger) Debug

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

Debug is equivalent to l.For(LevelDebug).Print(v...)

func (*Logger) Debugf

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

Debugf is equivalent to l.For(LevelDebug).Printf(format, v...)

func (*Logger) Debugln

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

Debugln is equivalent to l.For(LevelDebug).Println(v...)

func (*Logger) Error

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

Error is equivalent to l.For(LevelError).Print(v...)

func (*Logger) Errorf

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

Errorf is equivalent to l.For(LevelError).Printf(format, v...)

func (*Logger) Errorln

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

Errorln is equivalent to l.For(LevelError).Println(v...)

func (*Logger) Fatal

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

Fatal is equivalent to l.For(LevelError).Fatal(v...) Note that the program will exit even if the Error level is diabled.

func (*Logger) Fatalf

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

Fatalf is equivalent to l.For(LevelError).Fatalf(format, v...) Note that the program will exit even if the Error level is diabled.

func (*Logger) Fatalln

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

Fatalln is equivalent to l.For(LevelError).Fatalln(v...) Note that the program will exit even if the Error level is diabled.

func (*Logger) For

func (l *Logger) For(level Level) *log.Logger

For returns the Logger to use for the given level.

func (*Logger) Info

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

Info is equivalent to l.For(LevelInfo).Print(v...)

func (*Logger) Infof

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

Infof is equivalent to l.For(LevelInfo).Printf(format, v...)

func (*Logger) Infoln

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

Infoln is equivalent to l.For(LevelInfo).Println(v...)

func (*Logger) IsEnabled

func (l *Logger) IsEnabled(level Level) bool

IsEnabled returns whether level is enabled or not.

func (*Logger) Level

func (l *Logger) Level() Level

Level returns the currently enabled level

func (*Logger) Panic

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

Panic is equivalent to l.For(LevelError).Panic(v...) Note that panic() will be called even if the Error level is diabled.

func (*Logger) Panicf

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

Panicf is equivalent to l.For(LevelError).Panicf(format, v...) Note that panic() will be called even if the Error level is diabled.

func (*Logger) Panicln

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

Panicln is equivalent to l.For(LevelError).Panicln(v...) Note that panic() will be called even if the Error level is diabled.

func (*Logger) Print

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

Print is equivalent to l.Info(v...)

func (*Logger) Printf

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

Printf is equivalent to l.Infof(format, v...)

func (*Logger) Println

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

Println is equivalent to l.Infoln(v...)

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel changes the minimal enabled log level. All loggers below level are disabled, other loggers are enabled.

func (*Logger) Warn

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

Warn is equivalent to l.For(LevelWarn).Print(v...)

func (*Logger) Warnf

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

Warnf is equivalent to l.For(LevelWarn).Printf(format, v...)

func (*Logger) Warnln

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

Warnln is equivalent to l.For(LevelWarn).Println(v...)

Jump to

Keyboard shortcuts

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