timestamper

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StdoutType StreamType = 'O'
	StderrType StreamType = 'E'

	PartialLineType LineType = '+'
	FullLineType    LineType = ' '
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LineType

type LineType byte

type Logger

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

Logger implements the standard io.Write interface and adds lightweight metadata in the form of: <date> <stream id><stream type><append flag><message>

Where: - <date> is a RFC3339 Nano formatted date - <stream id> is a 2-digit hex encoded user provided stream identifier - <stream type> is either 'stdout' or 'stderr' - <append flag> is either ' ' (no-op) or '+' (append line to last line) - <message> is a user provided message.

This format is intended to be well suited to CI/CD logs, where timed output can help determine the duration of executed commands.

A new log line is emitted for each new-line character (\n) found within data provided to Write().

A new log line is also emitted when a call to Write() contains a carriage return (\r) but no new-line character. Such writes are often used to display progress bars, so having them "flushed" to the underlying stream helps with live log viewing. The whole Write() — including any bytes after the last \r — goes into a single entry; the \r is treated as a flush hint, not a content boundary. Splitting at the \r would strand the trailing bytes (e.g. a `\x1b[0K` erase-line code paired with a section marker) in the buffer until the next write on this stream, attaching them to that later entry with a stale timestamp.

func New

func New(w io.Writer, streamType StreamType, streamNumber uint8, timestamp bool) *Logger

func (*Logger) Close

func (l *Logger) Close() error

func (*Logger) Write

func (l *Logger) Write(p []byte) (n int, err error)

type StreamType

type StreamType byte

Jump to

Keyboard shortcuts

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