notify

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsyncDiscard

func AsyncDiscard() chan<- *Entry

AsyncDiscard discards all notifications

func AsyncLogger

func AsyncLogger() (chan<- *Entry, chan bool)

AsyncLogger receives notification entries from a channel and logs them

Types

type Context

type Context struct {
	Fields Map `json:"data"`
	Extra  Map `json:"extra"`
}

Context holds stateful information for notifications

func WithError

func WithError(err error) Context

WithError creates a new context with an error

func WithExtra

func WithExtra(name string, value interface{}) Context

WithExtra creates a new context with an extra property

func WithField

func WithField(name string, value interface{}) Context

WithField creates a new context with a single field

func WithFields

func WithFields(f Fields) Context

WithFields creates a new context with multiple fields

func (Context) Debug

func (c Context) Debug(s string, v ...interface{}) *Entry

Debug creates a new debugging notification

func (Context) Error

func (c Context) Error(s string, v ...interface{}) *Entry

Error creates a new info notification

func (Context) Fatal

func (c Context) Fatal(s string, v ...interface{}) *Entry

Fatal creates a new info notification

func (Context) Info

func (c Context) Info(s string, v ...interface{}) *Entry

Info creates a new info notification

func (Context) Notify

func (c Context) Notify(l Level, s string, v ...interface{}) *Entry

Notify creates a new notification entry

func (Context) Warn

func (c Context) Warn(s string, v ...interface{}) *Entry

Warn creates a new info notification

func (Context) WithError

func (c Context) WithError(err error) Context

WithError extedns the current context with an error

func (Context) WithExtra

func (c Context) WithExtra(name string, value interface{}) Context

WithExtra adds additional information which is only used internally

func (Context) WithField

func (c Context) WithField(name string, value interface{}) Context

WithField extends the current context with anohter field

func (Context) WithFields

func (c Context) WithFields(f Fields) Context

WithFields extends the current context with multiple fields

type Entry

type Entry struct {
	Context
	Message string `json:"message"`
	Level   Level  `json:"level"`
}

Entry is a single instance of a notification

func Debug

func Debug(s string, v ...interface{}) *Entry

Debug creates a debuggin notification

func Error

func Error(s string, v ...interface{}) *Entry

Error creates a warn notification

func Fatal

func Fatal(s string, v ...interface{}) *Entry

Fatal creates a warn notification

func Info

func Info(s string, v ...interface{}) *Entry

Info creates a info notification

func Warn

func Warn(s string, v ...interface{}) *Entry

Warn creates a warn notification

func (*Entry) Error

func (e *Entry) Error() string

Error returns a string representation of the notification

type Fields

type Fields map[string]interface{}

Fields is a collection of key, value pairs

type Level

type Level uint32

Level is the notification level

const (
	// LevelDebug is for development notifications
	LevelDebug Level = iota

	// LevelInfo is for notifictions which are non-critical
	LevelInfo

	// LevelWarn is for notifications which may be troublesome
	LevelWarn

	// LevelError is for notifications which is crtical
	LevelError

	// LevelFatal is for notifications which are fatal
	LevelFatal
)

func (Level) MarshalJSON

func (l Level) MarshalJSON() ([]byte, error)

MarshalJSON returns the notification level as a string

func (Level) String

func (l Level) String() string

type Map

type Map map[string]interface{}

Map holds stateful information of key, value pairs

Jump to

Keyboard shortcuts

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