logger

package module
v0.0.0-...-d99d80e Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2016 License: MIT Imports: 3 Imported by: 3

README

logger

Documentation

Overview

Package logger provides a simple logging interface that supports multiple levels of logging. It goes up to 11.

Index

Constants

View Source
const (
	// Silent logs no output at all.
	Silent = iota

	// Error logs only errors.
	Error = iota

	// Blocked logs blocking calls and lower.
	Blocked = iota

	// Unblocked logs all unblocked notifications and lower.
	Unblocked = iota

	// Warn logs warnings and lower.
	Warn = iota

	// Reject logs rejections (e.g., in a firewall) and lower.
	Reject = iota

	// Listen logs listeners and lower.
	Listen = iota

	// Install logs install notifications and lower.
	Install = iota

	// Init logs initialization notifications and lower.
	Init = iota

	// Request logs incoming requests and lower.
	Request = iota

	// Info logs info output and lower.
	Info = iota

	// Debug logs all log output.
	Debug = iota
)

Variables

View Source
var LogLevel = map[string]int{
	"silent":    Silent,
	"error":     Error,
	"blocked":   Blocked,
	"unblocked": Unblocked,
	"warn":      Warn,
	"reject":    Reject,
	"listen":    Listen,
	"install":   Install,
	"init":      Init,
	"request":   Request,
	"info":      Info,
	"debug":     Debug}

LogLevel translates human-readable log level names to their int values.

Functions

func MustBlocked

func MustBlocked(format string, v ...interface{})

MustBlocked logs a blocked message.

func MustDebug

func MustDebug(format string, v ...interface{})

MustDebug logs a debug message.

func MustError

func MustError(format string, v ...interface{})

MustError logs an error.

func MustInfo

func MustInfo(format string, v ...interface{})

MustInfo logs an info message.

func MustInit

func MustInit(format string, v ...interface{})

MustInit logs an initialization message.

func MustInstall

func MustInstall(format string, v ...interface{})

MustInstall logs an install message.

func MustListen

func MustListen(format string, v ...interface{})

MustListen logs a listener message.

func MustReject

func MustReject(format string, v ...interface{})

MustReject logs a rejection.

func MustRequest

func MustRequest(format string, v ...interface{})

MustRequest logs a request.

func MustUnblocked

func MustUnblocked(format string, v ...interface{})

MustUnblocked logs an unblocked message.

func MustWarn

func MustWarn(format string, v ...interface{})

MustWarn logs a warning.

Types

type Logger

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

Logger only outputs log messages that are equal or lower than its log level.

func New

func New(level int) (*Logger, error)

New instantiates a Logger and sets its level. If the level is invalid, it returns an error.

func (*Logger) Blocked

func (l *Logger) Blocked(format string, v ...interface{})

Blocked logs a blocked message if logger level allows.

func (*Logger) Debug

func (l *Logger) Debug(format string, v ...interface{})

Debug logs a debug message if logger level allows.

func (*Logger) Error

func (l *Logger) Error(format string, v ...interface{})

Error logs an error if logger level allows.

func (*Logger) Info

func (l *Logger) Info(format string, v ...interface{})

Info logs an info message if logger level allows.

func (*Logger) Init

func (l *Logger) Init(format string, v ...interface{})

Init logs an initialization message if logger level allows.

func (*Logger) Install

func (l *Logger) Install(format string, v ...interface{})

Install logs an install message if logger level allows.

func (*Logger) Level

func (l *Logger) Level() int

Level returns a logger instance's log level if logger level allows.

func (*Logger) Listen

func (l *Logger) Listen(format string, v ...interface{})

Listen logs a listener message if logger level allows.

func (*Logger) Reject

func (l *Logger) Reject(format string, v ...interface{})

Reject logs a rejection if logger level allows.

func (*Logger) Request

func (l *Logger) Request(format string, v ...interface{})

Request logs a request if logger level allows.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level int) error

SetLevel sets a logger instance's log level if logger level allows.

func (*Logger) Unblocked

func (l *Logger) Unblocked(format string, v ...interface{})

Unblocked logs an unblocked notification if logger level allows.

func (*Logger) Warn

func (l *Logger) Warn(format string, v ...interface{})

Warn logs a warning if logger level allows.

Jump to

Keyboard shortcuts

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