log

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: Apache-2.0 Imports: 11 Imported by: 35

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultFormat = "%{color}%{time:15:04:05.000}: %{module} %{level} %{color:reset} %{message}"
	CliFormat     = "%{color}%{message}%{color:reset}"

	DefaultModuleLevel = ModuleLevel{"", DEBUG}
)

Log formats.

Functions

func FatalPanic

func FatalPanic(log Logger)

FatalPanic logs panic and crashes Gohan process

func Panic

func Panic(log Logger)

Panic logs panic and prevent crash

func SetUpBasicLogging

func SetUpBasicLogging(w io.Writer, format string, levels ...ModuleLevel)

SetUpBasicLogging configures logging to output logs to w, if levels are nil DefaultModuleLevel is used.

func SetUpLogging

func SetUpLogging(config *util.Config) error

SetUpLogging configures logging based on configuration

Types

type BufWritter

type BufWritter struct {
}

BufWritter is a thread safe in memory writer, different go routines trees write to different buffers.

func (BufWritter) Dump

func (w BufWritter) Dump(dst io.Writer)

Dump copies buffered bytes to dst.

func (BufWritter) Reset

func (w BufWritter) Reset()

Reset truncates buffer to 0.

func (BufWritter) Write

func (w BufWritter) Write(p []byte) (n int, err error)

type Level

type Level int

Level defines all available log levels for log messages.

const (
	CRITICAL Level = iota
	ERROR
	WARNING
	NOTICE
	INFO
	DEBUG
)

Level values.

type Logger

type Logger interface {
	// Fatal is equivalent to l.Critical(fmt.Sprint()) followed by a call to os.Exit(1).
	Fatal(args ...interface{})
	// Fatalf is equivalent to l.Critical followed by a call to os.Exit(1).
	Fatalf(format string, args ...interface{})
	// Panic is equivalent to l.Critical(fmt.Sprint()) followed by a call to panic().
	Panic(args ...interface{})
	// Panicf is equivalent to l.Critical followed by a call to panic().
	Panicf(format string, args ...interface{})
	// Critical logs a message using CRITICAL as log level.
	Critical(format string, args ...interface{})
	// Error logs a message using ERROR as log level.
	Error(format string, args ...interface{})
	// Warning logs a message using WARNING as log level.
	Warning(format string, args ...interface{})
	// Notice logs a message using NOTICE as log level.
	Notice(format string, args ...interface{})
	// Info logs a message using INFO as log level.
	Info(format string, args ...interface{})
	// Debug logs a message using DEBUG as log level.
	Debug(format string, args ...interface{})
}

Logger provides logging capabilities.

func NewLogger

func NewLogger() Logger

NewLogger creates new logger for automatically retrieved module name.

func NewLoggerForModule

func NewLoggerForModule(module string) Logger

NewLoggerForModule creates new logger for a given module name.

type ModuleLevel

type ModuleLevel struct {
	Module string
	Level  Level
}

ModuleLevel holds module name with desired log level.

Jump to

Keyboard shortcuts

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