log

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBatchedReader

func NewBatchedReader[T any](args NewBatchedReaderArgs[T]) core.Reader[[]T]

NewBatchedReader returns a reader which wraps args.Reader with logging.

Logging format:

{"time":"...","level":"...","msg":"...","err":"...","len":"...","ctx":{...}}

Logging format details:

  • "time": Format depends on args.Logger. Default is RFC3999.
  • "level": Normally INFO, may be ERROR on errs other than io.EOF.
  • "msg": Set to args.Msg. Will be "<unset>" if not set.
  • "err": Set to read errs.
  • "len": The len of values read from args.Reader.
  • "ctx": Key-val pairs from args.CtxKeys and ctx given to the reader.

Be sure to check out docs for NewBatchedReaderArgs, as behaviour depends a bit on what the arg struct contains.

func NewBatchedWriter

func NewBatchedWriter[T any](args NewBatchedWriterArgs[T]) core.Writer[[]T]

NewBatchedWriter returns a writer which accepts batches and passes them to args.Writer while logging with args.Logger.

Logging format:

{"time":"...","level":"...","msg":"...","err":"...","len":"...","ctx":{...}}

Logging format details:

  • "time": Format depends on args.Logger. Default is RFC3999.
  • "level": Normally INFO, may be ERROR on errs other than io.ErrClosedPipe.
  • "msg": Set to args.Msg. Will be "<unset>" if not set.
  • "err": Set to write errs.
  • "len": Set to the len of values put into this writer.
  • "ctx": Key-val pairs from args.CtxKeys and ctx given to the reader.

Be sure to check out docs for NewBatchedWriterArgs, as behaviour depends a bit on what the arg struct contains.

func NewStreamedReader

func NewStreamedReader[T any](args NewStreamedReaderArgs[T]) core.Reader[T]

NewStreamedReader returns a reader which wraps args.Reader with logging.

Logging format:

{"time":"...","level":"...","msg":"...","err":"...","val":"...","ctx":{...}}

Logging format details:

  • "time": Format depends on args.Logger. Default is RFC3999.
  • "level": Normally INFO, may be ERROR on errs other than io.EOF.
  • "msg": Set to args.Msg. Will be "<unset>" if not set.
  • "err": Set to read errs.
  • "val": Values from args.Reader, formatted by args.Fmt.
  • "ctx": Key-val pairs from args.CtxKeys and ctx given to the reader.

Be sure to check out docs for NewStreamedReaderArgs, as behaviour depends a bit on what the arg struct contains.

func NewStreamedWriter

func NewStreamedWriter[T any](args NewStreamedWriterArgs[T]) core.Writer[T]

NewStreamedWriter returns a writer which accepts values and passes them to args.Writer while logging with args.Logger.

Logging format:

{"time":"...","level":"...","msg":"...","err":"...","val":"...","ctx":{...}}

Logging format details:

  • "time": Format depends on args.Logger. Default is RFC3999.
  • "level": Normally INFO, may be ERROR on errs other than io.ErrClosedPipe.
  • "msg": Set to args.Msg. Will be "<unset>" if not set.
  • "err": Set to write errs.
  • "val": Set to values put into this writer, formatted by args.Fmt.
  • "ctx": Key-val pairs from args.CtxKeys and ctx given to the reader.

Be sure to check out docs for NewStreamedWriterArgs, as behaviour depends a bit on what the arg struct contains.

Types

type NewBatchedReaderArgs

type NewBatchedReaderArgs[T any] struct {
	Reader  core.Reader[[]T] // On nil, the func returns core.ReaderImpl[[]T]
	Logger  *slog.Logger     // On nil, will use a default logger.
	Msg     string           // On "" , will set the log "msg" to "<unset>"
	CtxKeys []string         // On nil, will set the log "ctx" to nil.
}

type NewBatchedWriterArgs

type NewBatchedWriterArgs[T any] struct {
	Writer  core.Writer[[]T] // On nil, the func returns core.WriterImpl[[]T]
	Logger  *slog.Logger     // On nil, will use a default logger.
	Msg     string           // On "" , will set the log "msg" to "<unset>"
	CtxKeys []string         // On nil, will set the log "ctx" to nil.
}

type NewStreamedReaderArgs

type NewStreamedReaderArgs[T any] struct {
	Reader  core.Reader[T] // On nil, the func returns core.ReaderImpl[T]
	Logger  *slog.Logger   // On nil, will use a default logger.
	Msg     string         // On "" , will set the log "msg" to "<unset>"
	Fmt     func(T) any    // On nil, will set the log "val" to the value of T.
	CtxKeys []string       // On nil, will set the log "ctx" to nil.
}

type NewStreamedWriterArgs

type NewStreamedWriterArgs[T any] struct {
	Writer  core.Writer[T] // On nil, the func returns core.WriterImpl[T]
	Logger  *slog.Logger   // On nil, will use a default logger.
	Msg     string         // On "" , will set the log "msg" to "<unset>"
	Fmt     func(T) any    // On nil, will set the log "val" to the value of T.
	CtxKeys []string       // On nil, will set the log "ctx" to nil.
}

Jump to

Keyboard shortcuts

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