logging

package
v0.9.0-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package logging provides a common Logger interface together with some infrastructure code. Integrations with other logging frameworks are provided in subpackages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestWriter

func TestWriter(delegate testDelegate) io.Writer

TestWriter produces an io.Writer that outputs to testDelegate.Log with a single string. Use this function to create a test logger: &LoggerWriter{TestWriter(t)}.

Types

type DefaultLoggerFactory

type DefaultLoggerFactory struct {
	Output io.Writer
}

DefaultLoggerFactory provides a simple way to create Logger instances adapted onto log.Logger.

func (*DefaultLoggerFactory) NewLogger

func (factory *DefaultLoggerFactory) NewLogger(name string) (Logger, error)

type ErrorLogger

type ErrorLogger interface {
	Error(parameters ...interface{})
}

ErrorLogger provides the interface for outputting errors to a log sink

type ErrorWriter

type ErrorWriter struct {
	ErrorLogger
}

ErrorWriter adapts io.Writer onto ErrorLogger so that all output from Write() goes to Error(...). This is useful for HTTP error logs.

func (*ErrorWriter) Write

func (e *ErrorWriter) Write(data []byte) (int, error)

type Logger

type Logger interface {
	ErrorLogger

	Trace(parameters ...interface{})
	Debug(parameters ...interface{})
	Info(parameters ...interface{})
	Warn(parameters ...interface{})
}

Logger defines the expected methods to be provided by logging infrastructure. This interface uses different idioms than those used by golang's stdlib Logger.

func DefaultLogger

func DefaultLogger() Logger

func TestLogger

func TestLogger(delegate testDelegate) Logger

TestLogger is a convenience for &LoggerWriter{TestWriter(t)}

type LoggerFactory

type LoggerFactory interface {
	// Returns a new, distinct Logger instance using this factory's configuration
	NewLogger(name string) (Logger, error)
}

LoggerFactory represents the behavior of a type which can create a Logger. Integrations must supply an implementation of this interface, typically configured through JSON.

type LoggerWriter

type LoggerWriter struct {
	io.Writer
}

LoggerWriter is a default, built-in logging type that simply writes output to an embedded io.Writer. This is a "poor man's" Logger. It should normally only be used in utilities and tests.

This logger will panic if any io errors occur.

func (*LoggerWriter) Debug

func (l *LoggerWriter) Debug(parameters ...interface{})

func (*LoggerWriter) Error

func (l *LoggerWriter) Error(parameters ...interface{})

func (*LoggerWriter) Info

func (l *LoggerWriter) Info(parameters ...interface{})

func (*LoggerWriter) Printf

func (l *LoggerWriter) Printf(format string, parameters ...interface{})

func (*LoggerWriter) Trace

func (l *LoggerWriter) Trace(parameters ...interface{})

func (*LoggerWriter) Warn

func (l *LoggerWriter) Warn(parameters ...interface{})

type PrintLogger

type PrintLogger struct {
	Delegate Logger
}

PrintLogger exposes a Printf method for infrastructure that uses that method for logging.

func (PrintLogger) Printf

func (printLogger PrintLogger) Printf(format string, parameters ...interface{})

Directories

Path Synopsis
Package golog integrates the WebPA common logging with github.com/ian-kent/go-log.
Package golog integrates the WebPA common logging with github.com/ian-kent/go-log.

Jump to

Keyboard shortcuts

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