log

package
v0.0.0-...-6b33518 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: AGPL-3.0-or-later, BSD-3-Clause Imports: 13 Imported by: 16

Documentation

Overview

Package log provides structured logging.

Index

Constants

This section is empty.

Variables

View Source
var StdLogger = &Logger{
	EntryHandler: &OutputText{
		Out:           Stderr,
		DisableColors: !isatty.IsTerminal(os.Stderr.Fd()),
	},
	Level: InfoLevel,
}

Functions

func Debug

func Debug(args ...interface{})

func Debugf

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

func Error

func Error(args ...interface{})

func Errorf

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

func Fatal

func Fatal(args ...interface{})

func Fatalf

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

func Info

func Info(args ...interface{})

func Infof

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

func Logfmt

func Logfmt(dst *bytes.Buffer, data map[string]interface{}, keyColors ...ansi.Code)

func Panic

func Panic(args ...interface{})

func Panicf

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

func Warn

func Warn(args ...interface{})

func Warnf

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

Types

type Entry

type Entry struct {
	Fields  Fields
	Time    time.Time
	Level   Level
	Message string
}

func (*Entry) JSON

func (e *Entry) JSON(w io.Writer) error

type EntryHandler

type EntryHandler interface {
	Fire(*Entry)
}

func OutputJSON

func OutputJSON(dst io.Writer) EntryHandler

type Fields

type Fields map[string]interface{}

type Level

type Level uint32

Level is a logging level. The levels are copied from logrus.

const (
	PanicLevel Level = iota
	FatalLevel
	ErrorLevel
	WarnLevel
	InfoLevel
	DebugLevel
)

func (Level) Color

func (level Level) Color() ansi.Code

func (Level) Icon

func (level Level) Icon() string

func (Level) String

func (level Level) String() string

type Logger

type Logger struct {
	EntryHandler
	Level Level
	// contains filtered or unexported fields
}

func WithFields

func WithFields(fields Fields) *Logger

func (*Logger) Clone

func (l *Logger) Clone() *Logger

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

func (*Logger) Debugf

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

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

func (*Logger) Errorf

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

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

func (*Logger) Fatalf

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

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

func (*Logger) Infof

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

func (*Logger) Panic

func (l *Logger) Panic(args ...interface{})

func (*Logger) Panicf

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

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

func (*Logger) Warnf

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

func (*Logger) WithFields

func (l *Logger) WithFields(fields Fields) *Logger

type MutexWriter

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

func NewMutexWriter

func NewMutexWriter(w io.Writer) *MutexWriter

func (*MutexWriter) Write

func (w *MutexWriter) Write(data []byte) (int, error)

type OutputDir

type OutputDir struct {
	// Dir is the directory that log files are written to in JSON-line format.
	Dir string
	// contains filtered or unexported fields
}

func (*OutputDir) Fire

func (h *OutputDir) Fire(e *Entry)

type OutputText

type OutputText struct {
	Out           io.Writer
	DisableColors bool
}

OutputText is an entry handler that writes a log entry as human-readable text to Out. The entry handler makes exactly one call to Out.Write for each entry.

func (*OutputText) Fire

func (h *OutputText) Fire(e *Entry)

Directories

Path Synopsis
Package ansi implements ANSI escape codes for terminal colors.
Package ansi implements ANSI escape codes for terminal colors.

Jump to

Keyboard shortcuts

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