logs

package
v9.0.0-...-93bb0e4 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package logs implements functions to manipulate logs.

Logs created are taggable.

logs.WithTags := logs.New("a log with tags").
    WithTag("a", 42).
    WithTag("b", 21)

Index

Constants

This section is empty.

Variables

View Source
var (
	// The function used to encode log entries and their tags.
	Encoder func(any) ([]byte, error)
)

Functions

func SetIndentEncoder

func SetIndentEncoder()

SetIndentEncoder is a helper function that set the logs encoder to a function that uses json.MarshalIndent.

func SetInlineEncoder

func SetInlineEncoder()

SetInlineEncoder is a helper function that set the logs encoder to json.Marshal.

Types

type Entry

type Entry struct {
	Line    string         `json:"line,omitempty"`
	Message string         `json:"message"`
	Tags    map[string]any `json:"tags,omitempty"`
}

A log entry.

func New

func New(v string) Entry

New returns a log with the given description that can be tagged.

func Newf

func Newf(msgFormat string, v ...any) Entry

Newf returns a log with the given formatted description that can be tagged.

func (Entry) String

func (e Entry) String() string

func (Entry) WithTag

func (e Entry) WithTag(k string, v any) Entry

WithTag sets the named tag with the given value.

Jump to

Keyboard shortcuts

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