log

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

README

log

Go Reference Go Report Go Version License Disgo Version Disgo Discord

The Logger interface can be used instead to give the user choice over which logger they want use

This lib ships with a default implementation of the Logger interface

SimpleLogger is a wrapped standard Logger to fit the Logger interface

You can use your own implementation or a library like logrus

Installing
go get github.com/DisgoOrg/log

Documentation

Index

Constants

View Source
const (
	Ldate         = 1 << iota     // the date in the local time zone: 2009/01/23
	Ltime                         // the time in the local time zone: 01:23:23
	Lmicroseconds                 // microsecond resolution: 01:23:23.123123.  assumes Ltime.
	Llongfile                     // full file name and line number: /a/b/c/d.go:23
	Lshortfile                    // final file name element and line number: d.go:23. overrides Llongfile
	LUTC                          // if Ldate or Ltime is set, use UTC rather than the local time zone
	Lmsgprefix                    // move the "prefix" from the beginning of the line to before the message
	LstdFlags     = Ldate | Ltime // initial values for the standard logger
)

These flags define which text to prefix to each log entry generated by the Logger. Bits are or'ed together to control what's printed. With the exception of the Lmsgprefix flag, there is no control over the order they appear (the order listed here) or the format they present (as described in the comments). The prefix is followed by a colon only when Llongfile or Lshortfile is specified. For example, flags Ldate | Ltime (or LstdFlags) produce,

2009/01/23 01:23:23 message

while flags Ldate | Ltime | Lmicroseconds | Llongfile produce,

2009/01/23 01:23:23.123123 /a/b/c/d.go:23: message

Variables

This section is empty.

Functions

func Debug added in v1.1.0

func Debug(args ...interface{})

Debug logs on the LevelDebug with the default SimpleLogger

func Debugf added in v1.1.0

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

Debugf logs on the LevelDebug with the default SimpleLogger

func Error added in v1.1.0

func Error(args ...interface{})

Error logs on the LevelError with the default SimpleLogger

func Errorf added in v1.1.0

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

Errorf logs on the LevelError with the default SimpleLogger

func Fatal added in v1.1.0

func Fatal(args ...interface{})

Fatal logs on the LevelFatal with the default SimpleLogger

func Fatalf added in v1.1.0

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

Fatalf logs on the LevelFatal with the default SimpleLogger

func Info added in v1.1.0

func Info(args ...interface{})

Info logs on the LevelInfo with the default SimpleLogger

func Infof added in v1.1.0

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

Infof logs on the LevelInfo with the default SimpleLogger

func Panic added in v1.1.0

func Panic(args ...interface{})

Panic logs on the LevelPanic with the default SimpleLogger

func Panicf added in v1.1.0

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

Panicf logs on the LevelPanic with the default SimpleLogger

func SetFlags added in v1.1.0

func SetFlags(flags int)

SetFlags sets the log flags like: Ldate, Ltime, Lmicroseconds, Llongfile, Lshortfile, LUTC, Lmsgprefix,LstdFlags of the default Logger

func SetLevel added in v1.1.0

func SetLevel(level Level)

SetLevel sets the Level of the default Logger

func Warn added in v1.1.0

func Warn(args ...interface{})

Warn logs on the LevelWarn with the default SimpleLogger

func Warnf added in v1.1.0

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

Warnf logs on the Level with the default SimpleLogger

Types

type Level added in v1.1.0

type Level int

Level are different levels at which the SimpleLogger can log

const (
	LevelDebug Level = iota
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
	LevelPanic
)

All Level(s) which SimpleLogger supports

func (Level) String added in v1.1.0

func (l Level) String() string

String returns the name of the Level

type Logger

type Logger interface {
	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
	Fatal(args ...interface{})
	Panic(args ...interface{})

	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
	Panicf(format string, args ...interface{})
}

Logger is the logging interface you can implement/use

type SimpleLogger added in v1.1.0

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

SimpleLogger is a wrapper for the std Logger

func Default added in v1.1.0

func Default() *SimpleLogger

Default returns the default SimpleLogger

func New added in v1.1.0

func New(flags int) *SimpleLogger

New returns a new SimpleLogger implementation

func (*SimpleLogger) Debug added in v1.1.0

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

Debug logs on the LevelDebug

func (*SimpleLogger) Debugf added in v1.1.0

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

Debugf logs on the LevelDebug

func (*SimpleLogger) Error added in v1.1.0

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

Error logs on the LevelError

func (*SimpleLogger) Errorf added in v1.1.0

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

Errorf logs on the LevelError

func (*SimpleLogger) Fatal added in v1.1.0

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

Fatal logs on the LevelFatal

func (*SimpleLogger) Fatalf added in v1.1.0

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

Fatalf logs on the LevelFatal

func (*SimpleLogger) Info added in v1.1.0

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

Info logs on the LevelInfo

func (*SimpleLogger) Infof added in v1.1.0

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

Infof logs on the LevelInfo

func (*SimpleLogger) Panic added in v1.1.0

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

Panic logs on the LevelPanic

func (*SimpleLogger) Panicf added in v1.1.0

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

Panicf logs on the LevelPanic

func (*SimpleLogger) SetFlags added in v1.1.0

func (l *SimpleLogger) SetFlags(flags int)

SetFlags sets the log flags like: Ldate, Ltime, Lmicroseconds, Llongfile, Lshortfile, LUTC, Lmsgprefix,LstdFlags

func (*SimpleLogger) SetLevel added in v1.1.0

func (l *SimpleLogger) SetLevel(level Level)

SetLevel sets the lowest Level to log for

func (*SimpleLogger) Warn added in v1.1.0

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

Warn logs on the LevelWarn

func (*SimpleLogger) Warnf added in v1.1.0

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

Warnf logs on the LevelWarn

Jump to

Keyboard shortcuts

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