dlog

package
v3.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2022 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Overview

Package dlog provides basic logging functions.

It is not intended to be a fully featured or fully optimized logger-- it is just enough of a logger for oak's needs. A program utilizing oak, if it wants more powerful logs, should log to a more powerful tool, and if desired, tell oak to as well via setting dlog.DefaultLogger.

Index

Constants

View Source
const (
	WindowClosed logCode = iota
	SceneStarting
	SceneLooping
	SceneEnding
	UnknownScene
	NoAudioDevice
)

Constant log string identifiers. All log strings output by oak should be enumerated here.

Variables

View Source
var DefaultLogger = NewLogger()

DefaultLogger is the Logger which all oak log messages are passed through.

Functions

func Error

func Error(vs ...interface{})

Error will write a log if the debug level is not NONE

func ErrorCheck

func ErrorCheck(in error) error

ErrorCheck checks that the input is not nil, then calls Error on it if it is not. Otherwise it does nothing. Emits the input error as is for additional processing if desired.

func Info

func Info(vs ...interface{})

Info will write a log if the debug level is higher than ERROR

func SetFilter

func SetFilter(filter func(string) bool)

SetFilter defines a custom filter function. Log lines that return false when passed to this function will not be output.

func SetLogLevel

func SetLogLevel(l Level) error

SetLogLevel sets the log level of the default logger.

func SetOutput

func SetOutput(w io.Writer)

SetOutput will output logs on the default logger to be written to the given writer.

func Verb

func Verb(vs ...interface{})

Verb will write a log if the debug level is higher than INFO

Types

type Level

type Level int

Level represents the levels a debug message can have

const (
	NONE Level = iota
	ERROR
	INFO
	VERBOSE
)

Level values const

func ParseDebugLevel

func ParseDebugLevel(level string) (Level, error)

ParseDebugLevel parses the input string as a known debug levels

func (Level) String

func (l Level) String() string

type Logger

type Logger interface {
	Error(...interface{})
	Info(...interface{})
	Verb(...interface{})
	SetFilter(func(string) bool)
	SetLogLevel(l Level) error
	SetOutput(io.Writer)
}

A Logger is a minimal log interface for the content oak wants to log: four levels of logging.

func NewLogger

func NewLogger() Logger

NewLogger returns an instance of the default logger with no filter, no file, and level set to ERROR

Jump to

Keyboard shortcuts

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