logger

package module
v0.0.0-...-1a14b8c Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2017 License: GPL-3.0 Imports: 8 Imported by: 1

README

logger

A small logger for Thingiversio

Documentation

Index

Constants

View Source
const (
	INFO    string = "INFO"
	INIT           = "INIT"
	ERROR          = "ERROR"
	FATAL          = "FATAL"
	DEBUG          = "DEBUG"
	SUCCESS        = "SUCCESS"
	WARNING        = "WARNING"
)

Variables

View Source
var DefaultLevels = map[string]Level{
	INFO:    Level{Name: INFO, Foreground: GREEN},
	INIT:    Level{Name: INIT, Foreground: BLUE, ForegroundHi: true},
	WARNING: Level{Name: WARNING, Background: YELLOW, BackgroundHi: true},
	ERROR:   Level{Name: ERROR, Foreground: WHITE, Background: RED},
	FATAL:   Level{Name: FATAL, Foreground: WHITE, Background: RED, BackgroundHi: true},
	SUCCESS: Level{Name: SUCCESS, Foreground: CYAN},
	DEBUG:   Level{Name: DEBUG, Background: YELLOW, BackgroundHi: true},
}

Functions

func Paint

func Paint(s string, foreground Color, foregroundHi bool, background Color, backgroundHi bool) string

Types

type Backend

type Backend interface {
	Write(msg Message)
}

type Color

type Color int
const (
	BLACK Color = iota
	RED
	GREEN
	YELLOW
	BLUE
	MAGENTA
	CYAN
	WHITE
)

https://en.wikipedia.org/wiki/ANSI_escape_code#Colors

func (Color) AsBackground

func (c Color) AsBackground() Color

func (Color) AsForeground

func (c Color) AsForeground() Color

func (Color) AsHiBackground

func (c Color) AsHiBackground() Color

func (Color) AsHiForeground

func (c Color) AsHiForeground() Color

type Level

type Level struct {
	Name string

	Foreground   Color
	ForegroundHi bool
	Background   Color
	BackgroundHi bool

	Display bool
}

type Logger

type Logger struct {
	Prefix string
	// contains filtered or unexported fields
}

func New

func New(prefix string) (logger *Logger)

func (*Logger) Debug

func (l *Logger) Debug(message ...interface{})

func (*Logger) Debugf

func (l *Logger) Debugf(format string, val ...interface{})

func (*Logger) Error

func (l *Logger) Error(message ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(format string, val ...interface{})

func (*Logger) Info

func (l *Logger) Info(message ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(format string, val ...interface{})

func (*Logger) Init

func (l *Logger) Init(message ...interface{})

func (*Logger) Initf

func (l *Logger) Initf(format string, val ...interface{})

func (*Logger) PrintSuccess

func (l *Logger) PrintSuccess()

func (*Logger) SetBackend

func (l *Logger) SetBackend(backend Backend) *Logger

func (*Logger) SetDebug

func (l *Logger) SetDebug(debug bool) *Logger

func (*Logger) SetTemplate

func (l *Logger) SetTemplate(tmpl string) *Logger

func (*Logger) Success

func (l *Logger) Success(message ...interface{})

func (*Logger) Successf

func (l *Logger) Successf(format string, val ...interface{})

type Message

type Message struct {
	Timestamp time.Time
	Prefix    string
	Level     Level
	Msg       string
	Nr        uint64
	// contains filtered or unexported fields
}

func NewMessage

func NewMessage(nr uint64, prefix string, lvl Level, tmpl *template.Template, format string, val ...interface{}) (m Message)

func (Message) Format

func (m Message) Format() string

func (Message) FormattedTime

func (m Message) FormattedTime() string

type MessageCollector

type MessageCollector struct {
	*eventual2go.Collector
}

func NewMessageCollector

func NewMessageCollector() *MessageCollector

func (*MessageCollector) Add

func (c *MessageCollector) Add(d Message)

func (*MessageCollector) AddFuture

func (c *MessageCollector) AddFuture(f *MessageFuture)

func (*MessageCollector) AddStream

func (c *MessageCollector) AddStream(s *MessageStream)

func (*MessageCollector) Get

func (c *MessageCollector) Get() Message

func (*MessageCollector) Preview

func (c *MessageCollector) Preview() Message

type MessageCompleter

type MessageCompleter struct {
	*eventual2go.Completer
}

func NewMessageCompleter

func NewMessageCompleter() *MessageCompleter

func (*MessageCompleter) Complete

func (c *MessageCompleter) Complete(d Message)

func (*MessageCompleter) Future

func (c *MessageCompleter) Future() *MessageFuture

type MessageCompletionHandler

type MessageCompletionHandler func(Message) Message

type MessageFilter

type MessageFilter func(Message) bool

type MessageFuture

type MessageFuture struct {
	*eventual2go.Future
}

func (*MessageFuture) AsChan

func (f *MessageFuture) AsChan() chan Message

func (*MessageFuture) Result

func (f *MessageFuture) Result() Message

func (*MessageFuture) Then

type MessageObservable

type MessageObservable struct {
	*eventual2go.Observable
}

func NewMessageObservable

func NewMessageObservable(value Message) (o *MessageObservable)

func (*MessageObservable) AsChan

func (o *MessageObservable) AsChan() (c chan Message, cancel *eventual2go.Completer)

func (*MessageObservable) Change

func (o *MessageObservable) Change(value Message)

func (*MessageObservable) NextChange

func (o *MessageObservable) NextChange() (f *MessageFuture)

func (*MessageObservable) OnChange

func (o *MessageObservable) OnChange(s MessageSubscriber) (cancel *eventual2go.Completer)

func (*MessageObservable) Stream

func (o *MessageObservable) Stream() *MessageStream

func (*MessageObservable) Value

func (o *MessageObservable) Value() Message

type MessageStream

type MessageStream struct {
	*eventual2go.Stream
}

func (*MessageStream) AsChan

func (s *MessageStream) AsChan() (c chan Message, stop *eventual2go.Completer)

func (*MessageStream) First

func (s *MessageStream) First() *MessageFuture

func (*MessageStream) FirstWhere

func (s *MessageStream) FirstWhere(f ...MessageFilter) *MessageFuture

func (*MessageStream) FirstWhereNot

func (s *MessageStream) FirstWhereNot(f ...MessageFilter) *MessageFuture

func (*MessageStream) Listen

func (*MessageStream) ListenNonBlocking

func (s *MessageStream) ListenNonBlocking(ss MessageSubscriber) *eventual2go.Completer

func (*MessageStream) Split

func (*MessageStream) TransformWhere

func (*MessageStream) Where

func (s *MessageStream) Where(f ...MessageFilter) *MessageStream

func (*MessageStream) WhereNot

func (s *MessageStream) WhereNot(f ...MessageFilter) *MessageStream

type MessageStreamController

type MessageStreamController struct {
	*eventual2go.StreamController
}

func NewMessageStreamController

func NewMessageStreamController() *MessageStreamController

func (*MessageStreamController) Add

func (sc *MessageStreamController) Add(d Message)

func (*MessageStreamController) Join

func (*MessageStreamController) JoinFuture

func (sc *MessageStreamController) JoinFuture(f *MessageFuture)

func (*MessageStreamController) Stream

func (sc *MessageStreamController) Stream() *MessageStream

type MessageSubscriber

type MessageSubscriber func(Message)

type WriterBackend

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

func NewWriterBackend

func NewWriterBackend(writer io.Writer) (b *WriterBackend)

func (*WriterBackend) Write

func (b *WriterBackend) Write(msg Message)

Jump to

Keyboard shortcuts

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