logger

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2016 License: MIT, MIT Imports: 4 Imported by: 0

README

go-logger

Logger for Go apps, this is an adapted code from Steve Francia's jWalterWeatherman library

Documentation

Overview

Package logger provides a logger for Centrifugo server. This is an adapted code from Steve Francia's jWalterWeatherman library - see https://github.com/spf13/jWalterWeatherman

Index

Constants

This section is empty.

Variables

View Source
var (
	DEBUG    *log.Logger
	INFO     *log.Logger
	WARN     *log.Logger
	ERROR    *log.Logger
	CRITICAL *log.Logger
	FATAL    *log.Logger

	LogHandle  io.Writer = ioutil.Discard
	OutHandle  io.Writer = os.Stdout
	BothHandle io.Writer = io.MultiWriter(LogHandle, OutHandle)

	Flag int = log.Ldate | log.Ltime

	NotePads []*NotePad = []*NotePad{debug, info, warn, err, critical, fatal}
)
View Source
var LevelMatches = map[string]Level{
	"DEBUG":    LevelDebug,
	"INFO":     LevelInfo,
	"WARN":     LevelWarn,
	"ERROR":    LevelError,
	"CRITICAL": LevelCritical,
	"FATAL":    LevelFatal,
	"NONE":     LevelNone,
}

Functions

func SetLogFile

func SetLogFile(path string) error

Conveniently Sets the Log Handle to a io.writer created for the file behind the given filepath Will only append to this file

func SetLogFlag

func SetLogFlag(flag int)

func SetLogThreshold

func SetLogThreshold(level Level)

Establishes a threshold where anything matching or above will be logged

func SetStdoutThreshold

func SetStdoutThreshold(level Level)

Establishes a threshold where anything matching or above will be output

Types

type Level

type Level int

Level describes the chosen log level

const (
	LevelDebug Level = iota
	LevelInfo
	LevelWarn
	LevelError
	LevelCritical
	LevelFatal
	LevelNone

	DefaultLogThreshold    = LevelInfo
	DefaultStdoutThreshold = LevelInfo
)

type NotePad

type NotePad struct {
	Handle io.Writer
	Level  Level
	Prefix string
	Logger **log.Logger
}

Jump to

Keyboard shortcuts

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