logger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package logger is a simplified logger which only handles two basic log levels.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Success colors a message in bold green to represent success.
	Success = color.New(color.FgGreen, color.Bold).SprintFunc()

	// Failure colors a message in bold red to represent failure.
	Failure = color.New(color.FgRed, color.Bold).SprintFunc()

	// Trace colors a message in faint white (usually rendered in gray)
	// to represent a log of low importance for the user.
	Trace = color.New(color.FgHiWhite, color.Faint).SprintFunc()

	// Important colors a message in bold to represent an important
	// information.
	Important = color.New(color.Bold).SprintFunc()

	// Link colors a message in underlined blue to represent a clickable link.
	Link = color.New(color.FgBlue, color.Underline).SprintFunc()
)

Functions

func WithColors

func WithColors(enabled bool) func(*Logger)

WithColors sets the use of colors in the logger. By default, whether or not colors are enabled depends on the user's TTY, but this option can be used to force colors to be enabled or disabled.

func WithDebug

func WithDebug(enabled bool) func(*Logger)

WithDebug sets the logger debug mode to true.

func WithErrorOutput

func WithErrorOutput(w io.Writer) func(*Logger)

WithErrorOutput binds a second writer on the logger, for logging errors.

Types

type Logger

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

Logger represents a disgo Logger. It writes the output on a given io.Writer and can toggle debug logs and have an error writer.

func New

func New(w io.Writer, options ...func(*Logger)) (*Logger, error)

New creates a new Logger and binds the given writer to its outputs.

func (Logger) Debug

func (l Logger) Debug(a ...interface{})

Debug writes a debug log on the logger's standard writer if the debug logs are enabled.

func (Logger) Debugf

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

Debugf formats according to a format specifier and writes to the logger's standard writer if the debug logs are enabled.

func (Logger) Debugln

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

Debugln writes a debug log on the logger's standard writer if

the debug logs are enabled and appends a newline to its input.

func (Logger) Error

func (l Logger) Error(a ...interface{})

Error writes an error log on the logger's error writer.

func (Logger) Errorf

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

Errorf formats according to a format specifier and writes to the logger's error writer.

func (Logger) Errorln

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

Errorln writes an error log on the logger's error writer. It appends a newline to its input.

func (Logger) Info

func (l Logger) Info(a ...interface{})

Info writes an info log on the logger's standard writer.

func (Logger) Infof

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

Infof formats according to a format specifier and writes to the logger's standard writer.

func (Logger) Infoln

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

Infoln writes an info log on the logger's standard writer and appends a newline to its input.

Jump to

Keyboard shortcuts

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