logger

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Overview

Package logger is the central log repository for gopher2600. There is a single log for the entire application and can be accessed through the package level functions.

New log entries are made with the package level Log() and Logf() functions. Both these functions require an implementation of the Permission interface. This interface tests whether the environment making the logging request is allowed to make new log entries.

The environment.Environment type satisfies the Permission interface. If it's not convenient to provide an instance of that type then logging.Allow can be used to provide blanket permission to the caller.

The Colorizer type can be used with SetEcho() to output a simply coloured log entries (using ANSI control codes).

The logger package should not be used inside any init() function.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BorrowLog added in v0.16.0

func BorrowLog(f func([]Entry))

BorrowLog gives the provided function the critial section and access to the list of log entries.

func Clear

func Clear()

Clear all entries from central logger.

func Log

func Log(perm Permission, tag, detail string)

Log adds an entry to the central logger

func Logf added in v0.10.1

func Logf(perm Permission, tag, detail string, args ...interface{})

Logf adds a formatted entry to the central logger

func SetEcho added in v0.7.1

func SetEcho(output io.Writer, writeRecent bool)

SetEcho prints log entries to io.Writer.

func Tail

func Tail(output io.Writer, number int)

Tail writes the last N entries to io.Writer.

func Write

func Write(output io.Writer)

Write contents of central logger to io.Writer.

func WriteRecent added in v0.7.1

func WriteRecent(output io.Writer)

WriteRecent returns only the entries added since the last call to CopyRecent.

Types

type Entry

type Entry struct {
	Time     time.Time
	Tag      string
	Detail   string
	Repeated int
}

Entry represents a single line/entry in the log.

func (*Entry) String added in v0.7.1

func (e *Entry) String() string

type Permission added in v0.31.0

type Permission interface {
	AllowLogging() bool
}

Permission implementatins indicate whether the environment making a log request is allowed to create new log entries

var Allow Permission = allow{}

Allow indicates that the logging request should be allowed

Jump to

Keyboard shortcuts

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