Documentation ¶
Overview ¶
Package logrotate implements additional functionality for io writers & closers
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Initialize ¶
func Initialize(logFolder, baseFilename string, maxAge, maxSize int, buffered bool, extraSink io.Writer) (io.Closer, error)
Initialize creates a lumberjack log rotator and redirects logs output to it. To ensure that any queued/buffered but unwritten log entries are flushed to disk call Stop() on the returned stopper before exiting the process. Once stopped, you can't resume the logger, you need to create a new one.
Types ¶
type ChannelWriter ¶
type ChannelWriter struct {
// contains filtered or unexported fields
}
ChannelWriter provides an io.Writer that defers the write to a background go routine. You might for example use this for a log.Logger destination
func NewChannelWriter ¶
NewChannelWriter provides an instance of io.Writer that forwards all write over a channel to a background go routine that does the actual write, this can stop disk I/O cluttering up app processing. [at the potential risk of loosing some writes during a crash]
dest is the io.Writer that we're wrapping bufferDepth controls the size of the channel buffer (if this buffer fills, it'll start to block the writers) flushInterval if the writer is a bufio.Writer (or any other writer with a Flush() error method), then we'll flush at this interval when there are no writes. you can pass zero for this if you don't want this behavour
func (*ChannelWriter) IsStopped ¶
func (cw *ChannelWriter) IsStopped() bool
IsStopped returns true if this ChannelWriter has been stopped
func (*ChannelWriter) Stop ¶
func (cw *ChannelWriter) Stop()
Stop tells the background writer to stop processing [if its running] Once stopped you can not restart it, it is expected that you throw this away once stopped. Stop will drain the current contents of the write channel before stopping Stop() will block until the channel is drained and the output flushed.