msg

package
v2.5.3 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MsgPool = sync.Pool{
	New: func() interface{} {
		return &Message{}
	},
}

MsgPool is a synchronized pool of messages

Functions

This section is empty.

Types

type Color

type Color func(string, ...interface{}) string

Color adds color codes to a string

type Field

type Field [2]interface{}

Field is a key-value pair

type Format

type Format func(msg *Message)

Format formats and prints out a log message

type Message

type Message struct {
	Time      string
	Name      string
	Text      string
	Level     int
	Threshold int
	HasColor  bool
	Stdout    *os.File
	Stderr    *os.File
	Print     Format
	Data      []interface{}
}

Message is a log message that gets built in multiple steps

func (*Message) Debug

func (msg *Message) Debug(format string, args ...interface{})

Debug outputs the message with level Debug

func (*Message) Error

func (msg *Message) Error(format string, args ...interface{})

Error outputs the message with level Error

func (*Message) Exit

func (msg *Message) Exit(code int, format string, args ...interface{})

Exit outputs the message as an error and exits with the given code

func (*Message) Fatal

func (msg *Message) Fatal(format string, args ...interface{})

Fatal outputs the message as an error and exits with code 1

func (*Message) Field

func (msg *Message) Field(name string, value interface{}) *Message

Field adds a data field to the message

func (*Message) Fields

func (msg *Message) Fields(fields ...Field) *Message

Fields adds multiple fields to the message

func (*Message) Info

func (msg *Message) Info(format string, args ...interface{})

Info outputs the message with level Info

func (*Message) Log

func (msg *Message) Log(level int, format string, args ...interface{})

Log outputs the message with the specified level

func (*Message) Panic

func (msg *Message) Panic(format string, args ...interface{})

Panic outputs the message as an error and panics

func (*Message) Props

func (msg *Message) Props() (stream *os.File, level string, color Color)

Props returns the message stream, level, and color

func (*Message) Trace

func (msg *Message) Trace(format string, args ...interface{})

Trace outputs the message with level Trace

func (*Message) Warn

func (msg *Message) Warn(format string, args ...interface{})

Warn outputs the message with level Warn

Jump to

Keyboard shortcuts

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