logutil

package
Version: v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 18, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Default A global variable so that log functions can be directly accessed
	Default = Logger(nil)
)

Functions

func Debug

func Debug(args ...interface{})

Debug ...

func Debugf

func Debugf(format string, args ...interface{})

Debugf ...

func Error

func Error(args ...interface{})

Error ...

func Errorf

func Errorf(format string, args ...interface{})

Errorf ...

func Fatal

func Fatal(args ...interface{})

Fatal ...

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf ...

func Flush

func Flush() error

Flush ..

func Info

func Info(args ...interface{})

Info ...

func Infof

func Infof(format string, args ...interface{})

Infof ...

func Panic

func Panic(args ...interface{})

Panic ...

func Panicf

func Panicf(format string, args ...interface{})

Panicf ...

func Register

func Register(name string, provider LoggerProvider)

Register registers a logger provider

func Warn

func Warn(args ...interface{})

Warn ...

func Warnf

func Warnf(format string, args ...interface{})

Warnf ...

Types

type Fields

type Fields map[string]interface{}

Fields Type to pass when we want to call WithFields for structured logging

type LogLevel

type LogLevel string

LogLevel ..

const (
	//DebugLevel has verbose message
	DebugLevel LogLevel = "debug"
	//InfoLevel is default log level
	InfoLevel LogLevel = "info"
	//WarnLevel is for logging messages about possible issues
	WarnLevel LogLevel = "warn"
	//ErrorLevel is for logging errors
	ErrorLevel LogLevel = "error"
	//FatalLevel is for logging fatal messages. The sytem shutsdown after logging the message.
	FatalLevel LogLevel = "fatal"
)

type Logger

type Logger interface {
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})

	Info(args ...interface{})
	Infof(format string, args ...interface{})

	Warn(args ...interface{})
	Warnf(format string, args ...interface{})

	Error(args ...interface{})
	Errorf(format string, args ...interface{})

	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})

	Panic(args ...interface{})
	Panicf(format string, args ...interface{})

	// WithFields return a logger with fields
	WithFields(fields Fields) Logger
	// Flush the log
	Flush() error
}

Logger is our contract for the logger

func NewLogger

func NewLogger(options ...LoggerOption) (Logger, error)

NewLogger converts from xml to json

func WithFields

func WithFields(keyValues Fields) Logger

WithFields ...

type LoggerOption

type LoggerOption func(*LoggerOptions) error

LoggerOption ...

func WithJSONFormat

func WithJSONFormat(jsonFormat bool) LoggerOption

WithJSONFormat ...

func WithLevel

func WithLevel(level LogLevel) LoggerOption

WithLevel ...

func WithOutput

func WithOutput(output io.Writer) LoggerOption

WithOutput ...

func WithPresets

func WithPresets(fields Fields) LoggerOption

WithPresets ...

func WithProvider

func WithProvider(provider string) LoggerOption

WithProvider ...

func WithReplaceDefaultLogger

func WithReplaceDefaultLogger(replace bool) LoggerOption

WithReplaceDefaultLogger ...

func WithRollingFiles

func WithRollingFiles(filename string, maxSizeMBs, maxBackups, maxAgeDays int) LoggerOption

WithRollingFiles ...

type LoggerOptions

type LoggerOptions struct {
	// contains filtered or unexported fields
}

LoggerOptions ...

type LoggerProvider

type LoggerProvider interface {
	// NewLogger creates a new logger
	NewLogger(output io.Writer, level LogLevel, jsonFormat bool, fields Fields) (Logger, error)
}

LoggerProvider ..

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL