logtest

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBuffCore

func NewBuffCore(ws *Buffer) zapcore.Core

func NewBuffLogger

func NewBuffLogger(ws *Buffer, opts ...zap.Option) *zap.Logger

Types

type Buffer

type Buffer struct {
	bytes.Buffer
	Syncer
}

Buffer is an implementation of zapcore.WriteSyncer that sends all writes to a bytes.Buffer. It has convenience methods to split the accumulated buffer on newlines.

func (*Buffer) LastLine

func (b *Buffer) LastLine() string

func (*Buffer) Lines

func (b *Buffer) Lines() []string

Lines returns the current buffer contents, split on newlines.

func (*Buffer) Stripped

func (b *Buffer) Stripped() string

Stripped returns the current buffer contents with the last trailing newline stripped.

type Discarder

type Discarder struct{ Syncer }

A Discarder sends all writes to io.Discard.

func (*Discarder) Write

func (d *Discarder) Write(b []byte) (int, error)

Write implements io.Writer.

type FailWriter

type FailWriter struct{ Syncer }

FailWriter is a WriteSyncer that always returns an error on writes.

func (FailWriter) Write

func (w FailWriter) Write(b []byte) (int, error)

Write implements io.Writer.

type ShortWriter

type ShortWriter struct{ Syncer }

ShortWriter is a WriteSyncer whose write method never fails, but nevertheless fails to the last byte of the input.

func (ShortWriter) Write

func (w ShortWriter) Write(b []byte) (int, error)

Write implements io.Writer.

type Syncer

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

A Syncer is a spy for the Sync portion of zapcore.WriteSyncer.

func (*Syncer) Called

func (s *Syncer) Called() bool

Called reports whether the Sync method was called.

func (*Syncer) SetError

func (s *Syncer) SetError(err error)

SetError sets the error that the Sync method will return.

func (*Syncer) Sync

func (s *Syncer) Sync() error

Sync records that it was called, then returns the user-supplied error (if any).

Jump to

Keyboard shortcuts

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