logring

package
v0.0.1-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: BSD-3-Clause, BSD-3-Clause Imports: 5 Imported by: 0

README

Log Ring

Ring buffer for storing log messages

Documentation

Overview

Package logring - Ring buffer for log messages

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ring

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

Ring is a ring buffer. Each call to Ring.Write stores a log message. All of Ring's methods are safe for concurrent use.

func New

func New(n int) *Ring

New returns a new ring which stores the last n messages written to it.

func (*Ring) Cap

func (r *Ring) Cap() int

Cap returns the capacity of the buffer. This is the value passed to New.

func (*Ring) Len

func (r *Ring) Len() int

Len returns the number of messages stored in the buffer.

func (*Ring) Messages

func (r *Ring) Messages() []string

Messages returns the messages stored in the Ring. The messages will not end in a newline.

func (*Ring) MessagesAndClear

func (r *Ring) MessagesAndClear() []string

MessagesAndClear is like Messages, but also clears the buffer.

func (*Ring) Printf

func (r *Ring) Printf(format string, v ...any)

Printf is like log.Printf, but log lines are stored in r.

Jump to

Keyboard shortcuts

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