ts

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: BSD-3-Clause Imports: 4 Imported by: 8

Documentation

Overview

Package ts contains a Transform to prepend a timestamp in front of each line.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultFormat

func DefaultFormat(startTime time.Time) string

DefaultFormat formats in seconds since the startTime. Ex: [12.3456s]

func NewRelativeFormat

func NewRelativeFormat() func(time.Time) string

NewRelativeFormat returns a format function which formats in seconds since the previous line. Ex: [+1.0050s]

Types

type PrependTimestamp

type PrependTimestamp struct {
	R         io.Reader
	StartTime time.Time
	Format    func(startTime time.Time) string

	// ResetTimeOnNextRead is set to force the StartTime to reset to the
	// current time when data is next read. It is useful to set this to
	// true initially for all times to be relative to the first line.
	ResetTimeOnNextRead bool
	// contains filtered or unexported fields
}

PrependTimestamp is an io.Reader which prepends a timestamp on each line.

func New

func New(r io.Reader) *PrependTimestamp

New creates a PrependTimestamp with default settings.

func (*PrependTimestamp) Read

func (t *PrependTimestamp) Read(p []byte) (n int, err error)

Read prepends a timestamp on each line.

Jump to

Keyboard shortcuts

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