overlog

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package overlog provides a reference logging implementation for Scribe. Besides being a minimal logger, Overlog provides support for capturing site-specific metadata and logging from concurrent applications, preventing the interleaving of logs across goroutine calls. Overlog also supports logging of raw strings, bypassing the formatter.

Index

Constants

View Source
const (
	// TimestampLayoutDateTime is a full layout containing both a date and a time portion.
	TimestampLayoutDateTime = "2006-01-02 15:04:05.000"

	// TimestampLayoutTimeOnly contains only the time.
	TimestampLayoutTimeOnly = "15:04:05.000"

	// TimestampLayoutDefault is the default layout applied in the formatter returned by Timestamp().
	TimestampLayoutDefault = TimestampLayoutTimeOnly
)

Variables

This section is empty.

Functions

func Append

func Append(buffer *bytes.Buffer, str string)

Append writes a string into the buffer. If the buffer is non-empty, a leading space is inserted before the string is written.

func Bind

func Bind(logger Overlog) scribe.LoggerFactories

Bind creates a direct binding for the given logger.

Types

type Event

type Event struct {
	Timestamp time.Time
	Message   string
	Level     scribe.Level
	Scene     scribe.Scene
}

Event captures attributes of a single log record.

type Formatter

type Formatter func(buffer *bytes.Buffer, event Event)

Formatter specifies how a logging event should be rendered in a given output buffer.

func Format

func Format(formatters ...Formatter) Formatter

Format composes multiple formatters into one.

func Level

func Level() Formatter

Level is a formatter that prints the level of the log event.

func Message

func Message() Formatter

Message is a formatter that prints the formatted message.

func Scene

func Scene() Formatter

Scene is a formatter that prints the elements of the scene.

func StandardFormat

func StandardFormat() Formatter

StandardFormat produces a formatter that includes all conventional elements — the timestamp, log level, message, and the scene contents.

func Timestamp

func Timestamp(layout ...string) Formatter

Timestamp is a formatter that prints the timestamp of the log event using the layout supplied. If no layout is supplied, the TimestampLayoutDefault is used.

type Overlog

type Overlog interface {
	With(level scribe.Level, scene scribe.Scene) scribe.Logger
	Raw(str string)
	Tracef(format string, args ...interface{})
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
}

Overlog is a synchronized logger backed by an io.Writer, suitable for use in concurrent applications where an unsynchronized logger would result in interleaved log entries.

func New

func New(formatter Formatter, writer ...io.Writer) Overlog

New creates a synchronized logger backed by a given writer. If unspecified, os.Stdout will be used.

Jump to

Keyboard shortcuts

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