log

package module
v0.0.0-...-67d5968 Latest Latest
Warning

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

Go to latest
Published: May 3, 2019 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LoggerCtxKey   = &contextKey{"Logger"}
	LogEntryCtxKey = &contextKey{"LogEntry"}
)
View Source
var (
	DefaultLogger *logrus.Logger
	AlertFn       func(level logrus.Level, msg string)
)
View Source
var Local = logrus.New()
View Source
var Logger = logrus.New()

Functions

func Alert

func Alert(args ...interface{})

func Alertf

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

func Alertln

func Alertln(args ...interface{})

func Configure

func Configure(cfg Config, defaults logrus.Fields) (io.Closer, error)

func Debug

func Debug(args ...interface{})

func Debugf

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

func Debugln

func Debugln(args ...interface{})

func Error

func Error(args ...interface{})

func Errorf

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

func Errorln

func Errorln(args ...interface{})

func Fatal

func Fatal(args ...interface{})

func Fatalf

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

func Fatalln

func Fatalln(args ...interface{})

func Info

func Info(args ...interface{})

func Infof

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

func Infoln

func Infoln(args ...interface{})

func Log

func LogBody

func LogBody(next http.Handler) http.Handler

func Panic

func Panic(args ...interface{})

func Panicf

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

func Panicln

func Panicln(args ...interface{})

func Print

func Print(args ...interface{})

func PrintPanics

func PrintPanics(next http.Handler) http.Handler

PrintPanics is a development middleware that preempts the request logger and prints a panic message and stack trace to stdout.

func Printf

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

func Println

func Println(args ...interface{})

func RedirectStderrToFile

func RedirectStderrToFile(appName string, force_redirect bool)

func RedirectStdlogOutput

func RedirectStdlogOutput(logger *logrus.Logger)

func RequestLog

func RequestLog(r *http.Request) logrus.FieldLogger

func RequestLogger

func RequestLogger(logger *logrus.Logger) func(next http.Handler) http.Handler

RequestLogger is a middleware for the github.com/Sirupsen/logrus to log requests. It is equipt to handle recovery in case of panics and record the stack trace with a panic log-level.

func SetEntryField

func SetEntryField(ctx context.Context, key string, value interface{})

func SetEntryFields

func SetEntryFields(ctx context.Context, fields map[string]interface{})

func SetRequestEntryField

func SetRequestEntryField(r *http.Request, key string, value interface{})

func SetRequestEntryFields

func SetRequestEntryFields(r *http.Request, fields map[string]interface{})

func Setup

func Setup(cfg Config) (io.Closer, error)

func Warn

func Warn(args ...interface{})

func Warnf

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

func Warnln

func Warnln(args ...interface{})

func WithError

func WithError(err error) *logrus.Entry

func WithField

func WithField(key string, value interface{}) *logrus.Entry

func WithFields

func WithFields(fields logrus.Fields) *logrus.Entry

func WithLogEntry

func WithLogEntry(parent context.Context, logEntry *HTTPLoggerEntry) context.Context

func WithLoggerContext

func WithLoggerContext(parent context.Context, logger *logrus.Logger) context.Context

Types

type BaseConfig

type BaseConfig struct {
	Name   string `yaml:"name"`
	File   bool   `yaml:"file"`
	Stdout bool   `yaml:"stdout"`
}

type Config

type Config struct {
	Base     BaseConfig     `yaml:"base"`
	Logstash LogstashConfig `yaml:"logstash"`
}

type HTTPLogger

type HTTPLogger struct {
	Logger *logrus.Logger
}

func (*HTTPLogger) NewLogEntry

func (l *HTTPLogger) NewLogEntry(r *http.Request) *HTTPLoggerEntry

type HTTPLoggerEntry

type HTTPLoggerEntry struct {
	Logger logrus.FieldLogger // field logger interface, created by RequestLogger
	Level  *logrus.Level      // intended log level to write when request finishes
}

func (*HTTPLoggerEntry) Panic

func (l *HTTPLoggerEntry) Panic(rec interface{}, stack []byte)

func (*HTTPLoggerEntry) Write

func (l *HTTPLoggerEntry) Write(status, bytes int, elapsed time.Duration)

type LogstashConfig

type LogstashConfig struct {
	Host               string `yaml:"host"`
	TLS                bool   `yaml:"tls"`
	InsecureSkipVerify bool   `yaml:"insecure_skip_verify"`
}

func (LogstashConfig) Valid

func (this LogstashConfig) Valid() bool

Directories

Path Synopsis
bin

Jump to

Keyboard shortcuts

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