ilog

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package ilog provides a simple and lightweight logging framework for involucro. It is a Go-lang-y abbreviation for involucro logging.

All public methods in this package are thread-safe.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Debug is a level not printed by default with prefix "DEBU".
	Debug = ForLevelPrefix(-2, "DEBU")

	// Info is a level not printed by default with prefix "INFO".
	Info = ForLevelPrefix(-1, "INFO")

	// Warn is a level printed by default with prefix "WARN".
	Warn = ForLevelPrefix(0, "WARN")

	// Error is a level printed by default with prefix "ERRO".
	Error = ForLevelPrefix(1, "ERRO")
)
View Source
var StdLog = New()

StdLog is the default logger that is available in the global space.

Functions

func ColorfulPrintFunc

func ColorfulPrintFunc(b Bough)

ColorfulPrintFunc is a PrintFunc that formats the Bough nicely with colors (if supported).

Types

type Bough

type Bough struct {
	Level   int
	Prefix  string
	Message string
}

A Bough is an entry in a log.

type Ilog

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

Ilog is the context for all loggers. There is a default instance which is sufficient for most use cases.

func New

func New() *Ilog

New creates a new context.

func (*Ilog) ForLevelPrefix

func (i *Ilog) ForLevelPrefix(l int, prefix string) Logger

ForLevelPrefix gives a logger for level l and prefix p.

func (*Ilog) MinPrintLevel

func (i *Ilog) MinPrintLevel() int

MinPrintLevel returns the minimum required print level.

func (*Ilog) PrintFunc

func (i *Ilog) PrintFunc() PrintFunc

PrintFunc gives the function currently used for printing.

func (*Ilog) Send

func (i *Ilog) Send(b Bough)

Send handles a Bough and delivers it to the print function if the level of the bough is at least the minimum print level.

func (*Ilog) SetMinPrintLevel

func (i *Ilog) SetMinPrintLevel(level int)

SetMinPrintLevel sets the minimum required level for a Bough to be actually printed. Level 2 messages are only printed if the level is 2 or lower.

func (*Ilog) SetPrintFunc

func (i *Ilog) SetPrintFunc(f PrintFunc)

SetPrintFunc replaces the print function with f.

type Logger

type Logger interface {
	Logln(a ...interface{})
	Logf(f string, a ...interface{})
	// contains filtered or unexported methods
}

Logger provides functionality to log strings. It provides a ln variant which works like Sprint, and a f variant like Sprintf.

func ForLevelPrefix

func ForLevelPrefix(l int, prefix string) Logger

ForLevelPrefix gives a Logger that logs with level l and prefix p. It logs on the default logging context.

type PrintFunc

type PrintFunc func(b Bough)

PrintFunc is a function that is supposed to handle a bough, for example printing it on the terminal.

Jump to

Keyboard shortcuts

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