writer

package
v0.71.2-alpha2024122002 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package writer provides a writer that redirects Write requests to configured logger and level.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(writer *Writer)

Option is a function to set options for Writer.

func WithDefaultLevel

func WithDefaultLevel(level log.Level) Option

WithDefaultLevel sets the default log level for Writer in case the log level cannot be extracted from the message.

func WithLogger

func WithLogger(logger log.Logger) Option

WithLogger sets Logger to the Writer.

func WithMsgSeparator

func WithMsgSeparator(sep string) Option

WithMsgSeparator configures Writer to split the received text into string and log them as separate records.

func WithParseFunc

func WithParseFunc(fn WriterParseFunc) Option

WithParseFunc sets the parser func.

type Writer

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

Writer redirects Write requests to configured logger and level

func New

func New(opts ...Option) *Writer

New returns a new Writer instance with fields assigned to default values.

func (*Writer) SetOption

func (writer *Writer) SetOption(opts ...Option)

SetOption sets options to the `Writer`.

func (*Writer) Write

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

Write implements `io.Writer` interface.

type WriterParseFunc

type WriterParseFunc func(str string) (msg string, time *time.Time, level *log.Level, err error)

WriterParseFunc is a function used to parse records to extract the time and level from them.

Jump to

Keyboard shortcuts

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