log

package
v0.0.0-...-15325b8 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package log defines standard logging for pearl.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Err

func Err(logger Logger, err error, msg string)

Err logs an error with an additional message.

func Log

func Log(l Logger, lvl Level, msg string)

Log logs msg at level with the given Logger.

Types

type Level

type Level int

Level is a logging level.

const (
	LevelTrace Level = iota
	LevelDebug
	LevelInfo
	LevelNotice
	LevelWarn
	LevelError
)

Defined logging levels.

type Log15

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

Log15 adapts log15 loggers to the Logger interface.

func (Log15) Debug

func (l Log15) Debug(msg string)

func (Log15) Error

func (l Log15) Error(msg string)

func (Log15) Info

func (l Log15) Info(msg string)

func (Log15) Notice

func (l Log15) Notice(msg string)

func (Log15) Trace

func (l Log15) Trace(msg string)

func (Log15) Warn

func (l Log15) Warn(msg string)

func (Log15) With

func (l Log15) With(k string, v interface{}) Logger

type Logger

type Logger interface {
	// With adds key value pair(s) to the logging context.
	With(string, interface{}) Logger

	// Logging at levels used in the official Tor client.
	Trace(msg string)
	Debug(msg string)
	Info(msg string)
	Notice(msg string)
	Warn(msg string)
	Error(msg string)
}

Logger is the base interface for logging in the pearl packages.

func ForComponent

func ForComponent(logger Logger, name string) Logger

ForComponent adds a tag to the logger labelling the component the logger is for.

func ForConn

func ForConn(logger Logger, conn net.Conn) Logger

ForConn adds address tags to logger from the given network connection.

func NewDebug

func NewDebug() Logger

NewDebug builds a logger intended for debugging purposes.

func NewLog15

func NewLog15(base log15.Logger) Logger

func WithBytes

func WithBytes(logger Logger, key string, data []byte) Logger

func WithErr

func WithErr(logger Logger, err error) Logger

func WithTags

func WithTags(logger Logger, tags map[string]string) Logger

WithTags adds the tags to the logging context.

Jump to

Keyboard shortcuts

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