writer

package
v1.0.100 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package writer provides wrappers to the interface Writer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Null added in v0.6.0

func Null() iface.Writer

Null returns the null Writer.

func Report added in v0.6.0

func Report(_ []byte, _ *iface.Record, err error)

Report calls log.Output with the err.

func ReportDetails added in v0.6.0

func ReportDetails(bs []byte, _ *iface.Record, err error)

ReportDetails calls log.Output with the err and the bs.

func Wrap

func Wrap(writer io.Writer, handler ErrorHandler) iface.Writer

Wrap wraps an io.Writer to iface.Writer. The writer must NOT be nil.

Types

type Async added in v0.3.0

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

An Async is a Writer wrapper. All Writers an Async wraps switch into asynchronous mode.

All methods of an Async are concurrency safe. An Async MUST be created with NewAsync.

func NewAsync added in v0.3.0

func NewAsync(writer iface.Writer, cap int) *Async

NewAsync creates a new Async that wraps the writer. The writer must NOT be nil. The cap is the capacity of the internal channel of the Async and it must NOT be negative.

func (*Async) Abort added in v0.3.0

func (async *Async) Abort()

Abort closes the internal channel and ignores all logs in the channel. It does NOT close the underlying writer.

func (*Async) Close added in v0.3.0

func (async *Async) Close()

Close closes the internal channel and waits until all logs in the channel have been output. It does NOT close the underlying writer.

func (*Async) Len added in v0.5.0

func (async *Async) Len() int

Len returns the length of the internal channel.

func (*Async) Write added in v0.3.0

func (async *Async) Write(bs []byte, record *iface.Record)

Write implements the interface Writer. It sends the bs and record to the internal channel. Another goroutine will receive them from the channel and then calls the underlying Writer with them. If the channel is full, it blocks.

type ErrorHandler added in v0.6.0

type ErrorHandler func(bs []byte, record *iface.Record, err error)

The ErrorHandler type is a function type used to handle errors. Do NOT call any method of the Writer or the Logger within the function, or it may deadlock.

type Func added in v0.5.0

type Func func(bs []byte, record *iface.Record)

The Func type is a function wrapper to the interface Writer. Do NOT call any method of the Logger within the function, or it may deadlock.

func (Func) Write added in v0.5.0

func (fn Func) Write(bs []byte, record *iface.Record)

Write calls the underlying function. It implements the interface Writer.

type Wrapper

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

func (*Wrapper) Write

func (wrapper *Wrapper) Write(bs []byte, record *iface.Record)

Directories

Path Synopsis
Package file implements a file writer which implements the Writer.
Package file implements a file writer which implements the Writer.
socket
tcp
Package tcp implements a tcp socket writer which implements the Writer.
Package tcp implements a tcp socket writer which implements the Writer.
unix
Package unix implements a unix domain socket writer which implements the Writer.
Package unix implements a unix domain socket writer which implements the Writer.
Package syslog implements a syslog writer which implements the Writer.
Package syslog implements a syslog writer which implements the Writer.

Jump to

Keyboard shortcuts

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