writer

package
v0.0.0-...-2bd578f Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DummyLeveledWriter

type DummyLeveledWriter struct {
}

DummyLeveledWriter is a wrapper around an actual writer Do not do anything

func NewDummyLeveledWriter

func NewDummyLeveledWriter() *DummyLeveledWriter

NewDummyLeveledWriter returns a new instance of DummyLeveledWriter Do not write anything

func (*DummyLeveledWriter) Close

func (l *DummyLeveledWriter) Close() error

Close closes writer

func (*DummyLeveledWriter) GetLevel

func (l *DummyLeveledWriter) GetLevel() nlog.Level

GetLevel returns log level

func (*DummyLeveledWriter) Write

func (l *DummyLeveledWriter) Write(p []byte) (n int, err error)

Write Writes data

func (*DummyLeveledWriter) WriteIfLevel

func (l *DummyLeveledWriter) WriteIfLevel(lvl nlog.Level, p []byte) (n int, err error)

WriteIfLevel writes mesage if level is satisfied

type LeveledMultiWriter

type LeveledMultiWriter interface {
	io.WriteCloser
	WriteIfLevel(lvl nlog.Level, p []byte) (n int, err error)
	Remove(writers ...LeveledWriter)
	Append(writers ...LeveledWriter)
}

LeveledWriter is a wrapper around an actual writer. Not threadsafe

type LeveledWriter

type LeveledWriter interface {
	io.WriteCloser
	WriteIfLevel(lvl nlog.Level, p []byte) (n int, err error)
	GetLevel() nlog.Level
}

LeveledWriter is a wrapper around an actual writer. Not threadsafe

func NewSysLogWriter

func NewSysLogWriter(name string, l ...nlog.Level) LeveledWriter

NewSysLogWriter initializes a syslog writer wrapped in LeveledLogger

func SysLogWrapper

func SysLogWrapper(w SyslogWriter, l nlog.Level) LeveledWriter

SyslogLevelWriter wraps a SyslogWriter and call the right syslog level method matching the level.

type MultiWriter

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

MultiWriter is multi writer with log level filtering It wraps real writer and calls it for logs where logging level is satisfied Not concurrent safe

func NewMultiWriter

func NewMultiWriter(writers ...*Writer) *MultiWriter

NewMultiWriter returns a new instance of threadsafe writer which will write when level is satisfied

func (*MultiWriter) Append

func (t *MultiWriter) Append(writers ...LeveledWriter)

func (*MultiWriter) Close

func (t *MultiWriter) Close() (err error)

Close implements io.WriteCloser.

func (*MultiWriter) Remove

func (t *MultiWriter) Remove(writers ...LeveledWriter)

func (*MultiWriter) Write

func (t *MultiWriter) Write(p []byte) (n int, err error)

Write implements io.Writer.

func (*MultiWriter) WriteIfLevel

func (t *MultiWriter) WriteIfLevel(lvl nlog.Level, p []byte) (n int, err error)

WriteIfLevel calls write if current le₺vel is satisfied

type ParallelMultiWriter

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

ParallelMultiWriter is multi writer with log level filtering It wraps real writer and calls it for logs where logging level is satisfied Not concurrent safe

func NewParallelMultiWriter

func NewParallelMultiWriter(writers ...*ParallelWriter) *ParallelMultiWriter

NewParallelMultiWriter returns a new instance of threadsafe writer which will write when level is satisfied

func (*ParallelMultiWriter) Append

func (t *ParallelMultiWriter) Append(writers ...LeveledWriter)

func (*ParallelMultiWriter) Close

func (t *ParallelMultiWriter) Close() (err error)

Close implements io.WriteCloser.

func (*ParallelMultiWriter) Remove

func (t *ParallelMultiWriter) Remove(writers ...LeveledWriter)

func (*ParallelMultiWriter) Write

func (t *ParallelMultiWriter) Write(p []byte) (n int, err error)

Write implements io.Writer.

func (*ParallelMultiWriter) WriteIfLevel

func (t *ParallelMultiWriter) WriteIfLevel(lvl nlog.Level, p []byte) (n int, err error)

WriteIfLevel calls write if current le₺vel is satisfied

type ParallelWriter

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

ParallelWriter is writer with log level filtering It wraps real writer and calls it for logs where logging level is satisfied Not concurrent safe

func NewParellelWriter

func NewParellelWriter(w io.WriteCloser, l nlog.Level, chanSize int) *ParallelWriter

NewParellelWriter returns a new instance of threadsafe writer which will write when level is satisfied

func (*ParallelWriter) Close

func (l *ParallelWriter) Close() (err error)

Write implements io.WriteCloser.

func (*ParallelWriter) GetLevel

func (l *ParallelWriter) GetLevel() nlog.Level

GetLevel returns log level of current writer

func (*ParallelWriter) Start

func (l *ParallelWriter) Start(wg *sync.WaitGroup)

Start starts worker for writer

func (*ParallelWriter) Stop

func (l *ParallelWriter) Stop()

Stop stops worker for writer

func (*ParallelWriter) Write

func (l *ParallelWriter) Write(p []byte) (n int, err error)

Write implements io.Writer.

func (*ParallelWriter) WriteIfLevel

func (l *ParallelWriter) WriteIfLevel(lvl nlog.Level, p []byte) (n int, err error)

WriteIfLevel calls write if current le₺vel is satisfied

type SyslogWriter

type SyslogWriter interface {
	io.Writer
	Debug(m string) error
	Info(m string) error
	Warning(m string) error
	Err(m string) error
	Emerg(m string) error
	Crit(m string) error
}

SyslogWriter is an interface matching a syslog.Writer struct.

type Writer

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

Writer is writer with log level filtering It wraps real writer and calls it for logs where logging level is satisfied Not concurrent safe

func NewWriter

func NewWriter(w io.WriteCloser, l nlog.Level) *Writer

NewWriter returns a new instance of threadsafe writer which will write when level is satisfied

func (*Writer) Close

func (l *Writer) Close() (err error)

Write implements io.WriteCloser.

func (*Writer) GetLevel

func (l *Writer) GetLevel() nlog.Level

GetLevel returns log level of current writer

func (*Writer) Write

func (l *Writer) Write(p []byte) (n int, err error)

Write implements io.Writer.

func (*Writer) WriteIfLevel

func (l *Writer) WriteIfLevel(lvl nlog.Level, p []byte) (n int, err error)

WriteIfLevel calls write if current le₺vel is satisfied

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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