log

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2020 License: MIT Imports: 5 Imported by: 0

README

log

Package log provides a simplified interface for logging.

Documentation

Overview

Package log provides a simplified interface for interacting with logging systems. The default logger sends messages to os.Stdout unless changed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debugf

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

Debugf logs a Debugf message to the default logger.

func Errorf

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

Errorf logs an Errorf message to the default logger.

func Infof

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

Infof logs an Infof message to the default logger.

func Set

func Set(l Logger)

Set the default logger for this package.

func Warnf

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

Warnf logs a Warnf message to the default logger.

Types

type Color

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

Color write messages to a writer in a k="v" format for all the fields on a single line *with* color!

func NewColor

func NewColor(w io.Writer) *Color

NewColor creates a color writer that sends messages to the given io.Writer.

func (*Color) Debugf

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

Debugf logs a Debugf message.

func (*Color) Errorf

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

Errorf logs an Errorf message.

func (*Color) Infof

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

Infof logs an Infof message.

func (*Color) Warnf

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

Warnf logs a Warnf message.

func (*Color) WithFields

func (w *Color) WithFields(f map[string]interface{}) Logger

WithFields calls WithFields for the default logger.

type Entry

type Entry struct {
	When    time.Time              `json:"when"`
	Level   string                 `json:"level"`
	Message string                 `json:"message"`
	Fields  map[string]interface{} `json:"fields,omitempty"`
}

type Logger

type Logger interface {
	// Debugf logs very detailed information.
	Debugf(format string, args ...interface{})

	// Infof logs informative information.
	Infof(format string, args ...interface{})

	// Warnf logs information that suggests something my be wrong.
	Warnf(format string, args ...interface{})

	// Errorf logs information related to an error.
	Errorf(format string, args ...interface{})

	// WithFields creates a new logger that is identical to this
	// logger but with the given fields added to the field set.
	WithFields(map[string]interface{}) Logger
}

Logger is an interface this package uses to log to loggers that fulfull this interface.

func WithFields

func WithFields(f map[string]interface{}) Logger

WithFields calls WithFields for the default logger.

type Multi

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

Multi represents a Configurer that uses multiple configurations to provide values.

func NewMulti

func NewMulti(ll ...Logger) *Multi

Multi creates a log which logs to all the given loggers.

func (*Multi) Debugf

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

Debugf calls Debugf for all the loggers.

func (*Multi) Errorf

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

Errorf calls Errorf for all the loggers.

func (*Multi) Infof

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

Infof calls Infos for all the loggers.

func (*Multi) Warnf

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

Warnf calls Warnf for all the loggers.

func (*Multi) WithFields

func (m *Multi) WithFields(f map[string]interface{}) Logger

WithFields calls WithFields for the default logger.

type Writer

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

Write write messages to a writer in a k="v" format for all the fields on a single line.

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWrite creates a write that sends messages to the given io.Writer.

func (*Writer) Debugf

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

Debugf logs a Debugf message.

func (*Writer) Errorf

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

Errorf logs an Errorf message.

func (*Writer) Infof

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

Infof logs an Infof message.

func (*Writer) Warnf

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

Warnf logs a Warnf message.

func (*Writer) WithFields

func (w *Writer) WithFields(f map[string]interface{}) Logger

WithFields calls WithFields for the default logger.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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