log

package
v0.0.0-...-9082c2d Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2016 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Overview

Generic logger package

There are 3 loglevels for every Log. The user level is what should go into every log. These are log messages that normally appear in the logs. The verbose level should be used during development or when there is a problem with the service. The trace level is for debugging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Log

type Log struct {
	Level LogLevel
	// contains filtered or unexported fields
}

Log is the mail log structure. This should be used to do multi-level logging.

func DefaultLogger

func DefaultLogger(w io.Writer) *Log

DefaultLogger creates a Log with the recommended settings that writes to w.

func DefaultOSLogger

func DefaultOSLogger() *Log

DefaultOSLogger creates a Log with the recommended settings that writes to stdout.

func NewLogger

func NewLogger(user, verbose, trace Logger) *Log

NewLogger creates and sets up a Log struct.

func (*Log) AddPrefix

func (l *Log) AddPrefix(prefix string)

AddPrefix adds a prefix to all loggers.

func (*Log) Fatal

func (l *Log) Fatal(v ...interface{})

func (*Log) Fatalf

func (l *Log) Fatalf(format string, v ...interface{})

func (*Log) Fatalln

func (l *Log) Fatalln(v ...interface{})

func (*Log) Trace

func (l *Log) Trace() Logger

Trace returns the trace level logger.

func (*Log) User

func (l *Log) User() Logger

User returns the user level logger.

func (*Log) Verbose

func (l *Log) Verbose() Logger

Verbose returns the verbose level logger.

type LogLevel

type LogLevel int8
const (
	// User level log contains the most crucial information that should be logged.
	LOG_USER LogLevel = iota
	// Verbose level log contains information that help ops to troubleshoot issues.
	LOG_VERBOSE
	// Trace level log contains information that help developers to debug the service.
	LOG_TRACE
	LOG_OFF = -1
)

type Logger

type Logger interface {
	Print(v ...interface{})
	Printf(format string, v ...interface{})
	Println(v ...interface{})
}

Logger is an interface for something that logs. This is used as a wrapper over log.Log.

func TraceLogFactory

func TraceLogFactory(w io.Writer) Logger

TraceLogFactory creates a trace level logger with the default settings.

func UserLogFactory

func UserLogFactory(w io.Writer) Logger

UserLogFactory creates a user level logger with the default settings.

func VerboseLogFactory

func VerboseLogFactory(w io.Writer) Logger

VerboseLogFactory creates a verbose level logger with the default settings.

Jump to

Keyboard shortcuts

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