log

package module
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: MIT Imports: 9 Imported by: 15

README

go-log

Go-Log is a wrapper for go standard logger which allows to create custom log instances pointing to the same Stdout but different log levels and different runtime.Caller levels.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Constructor = NewLog(FileDepth(2))
View Source
var PrefixedStdLogger = Constructor.PrefixedLog(FileDepth(3))
View Source
var StdLogger = Constructor.Log(FileDepth(3))

Functions

func Debug

func Debug(message interface{}, params ...interface{})

func DebugContext

func DebugContext(ctx context.Context, message interface{}, params ...interface{})

func Error

func Error(message interface{}, params ...interface{})

func ErrorContext

func ErrorContext(ctx context.Context, message interface{}, params ...interface{})

func Fatal

func Fatal(message interface{}, params ...interface{})

func FatalContext

func FatalContext(ctx context.Context, message interface{}, params ...interface{})

func Info

func Info(message interface{}, params ...interface{})

func InfoContext

func InfoContext(ctx context.Context, message interface{}, params ...interface{})

func Trace

func Trace(message interface{}, params ...interface{})

func TraceContext

func TraceContext(ctx context.Context, message interface{}, params ...interface{})

func Warn

func Warn(message interface{}, params ...interface{})

func WarnContext

func WarnContext(ctx context.Context, message interface{}, params ...interface{})

func WithPrefix

func WithPrefix(p string, message interface{}) string

Types

type Level

type Level string
const (
	FATAL Level = `FATAL`
	ERROR Level = `ERROR`
	WARN  Level = `WARN`
	INFO  Level = `INFO`
	DEBUG Level = `DEBUG`
	TRACE Level = `TRACE`
)

type Log

type Log interface {
	Log(...Option) Logger
	SimpleLog() SimpleLogger
	PrefixedLog(...Option) PrefixedLogger
}

func NewLog

func NewLog(options ...Option) Log

type Logger

type Logger interface {
	Fatal(message interface{}, params ...interface{})
	Error(message interface{}, params ...interface{})
	Warn(message interface{}, params ...interface{})
	Debug(message interface{}, params ...interface{})
	Info(message interface{}, params ...interface{})
	Trace(message interface{}, params ...interface{})
	FatalContext(ctx context.Context, message interface{}, params ...interface{})
	ErrorContext(ctx context.Context, message interface{}, params ...interface{})
	WarnContext(ctx context.Context, message interface{}, params ...interface{})
	DebugContext(ctx context.Context, message interface{}, params ...interface{})
	InfoContext(ctx context.Context, message interface{}, params ...interface{})
	TraceContext(ctx context.Context, message interface{}, params ...interface{})
	SimpleLogger
}

func NewNoopLogger added in v1.2.2

func NewNoopLogger() Logger

type Option

type Option func(*logOptions)

func FileDepth

func FileDepth(d int) Option

func Prefixed

func Prefixed(prefix string) Option

func WithColors

func WithColors(enabled bool) Option

func WithFilePath

func WithFilePath(enabled bool) Option

func WithLevel

func WithLevel(level Level) Option

func WithStdOut

func WithStdOut(w io.Writer) Option

type PrefixedLogger

type PrefixedLogger interface {
	Fatal(prefix string, message interface{}, params ...interface{})
	Error(prefix string, message interface{}, params ...interface{})
	Warn(prefix string, message interface{}, params ...interface{})
	Debug(prefix string, message interface{}, params ...interface{})
	Info(prefix string, message interface{}, params ...interface{})
	Trace(prefix string, message interface{}, params ...interface{})
	FatalContext(ctx context.Context, prefix string, message interface{}, params ...interface{})
	ErrorContext(ctx context.Context, prefix string, message interface{}, params ...interface{})
	WarnContext(ctx context.Context, prefix string, message interface{}, params ...interface{})
	DebugContext(ctx context.Context, prefix string, message interface{}, params ...interface{})
	InfoContext(ctx context.Context, prefix string, message interface{}, params ...interface{})
	TraceContext(ctx context.Context, prefix string, message interface{}, params ...interface{})
	SimpleLogger
}

func NewPrefixedNoopLogger added in v1.2.2

func NewPrefixedNoopLogger() PrefixedLogger

type SimpleLogger

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

Directories

Path Synopsis
log

Jump to

Keyboard shortcuts

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