termlog

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package termlog writes a terminal session's log: the lines of its output as the terminal showed them, each with its time if asked, or the bytes it printed as they came, in a file of its own, under a folder of the host's. What is typed is never written, only what the session printed.

Index

Constants

This section is empty.

Variables

View Source
var ErrBacklog = errors.New("termlog: the log file is not keeping up")

ErrBacklog means the log fell too far behind its file, which stopped taking what was written: the log stops rather than hold it all.

Functions

func SafeName

func SafeName(name string) string

SafeName is name as a file or folder name on every system: what one of them refuses becomes "_", and it is never empty, a device's name, nor longer than 80 characters.

Types

type Header struct {
	// Name is the host's name, which also names its folder.
	Name string
	// Target is where it connects to, as user@host:port; "" for none.
	Target string
}

Header is what the first line of a log says about its session.

type Options

type Options struct {
	// Raw keeps the bytes printed, escape sequences and all (Raw), not the
	// lines shown (Line).
	Raw bool
	// Stamps starts each line with the time it was left.
	Stamps bool
}

Options are how a log is written.

type Recorder

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

Recorder writes one session's log. Line and Close may be called from any goroutine; Line never waits for the file.

func Start

func Start(dir string, h Header, o Options, now time.Time, changed func()) (*Recorder, error)

Start creates a log for the session h names, at now, in a folder of its own under dir; changed, when set, is told as it grows or fails.

func (*Recorder) Close

func (r *Recorder) Close(tail string, now time.Time) error

Close ends the log at now with tail, the line the session was on (not in a raw log, which has it already), and waits for the file: the error is why it failed, if it did.

func (*Recorder) Err

func (r *Recorder) Err() error

Err is why the log stopped writing, nil while it writes.

func (*Recorder) Line

func (r *Recorder) Line(text string, wrapped bool)

Line adds a line of output; wrapped says the next goes on in it, as vt.Terminal.SetLineHook tells.

func (*Recorder) Mark

func (r *Recorder) Mark(text string, now time.Time)

Mark adds a line of its own, text, as the session reconnects: the line left is ended first.

func (*Recorder) Path

func (r *Recorder) Path() string

Path is the log's file.

func (*Recorder) Raw

func (r *Recorder) Raw(p []byte)

Raw adds bytes printed, as they came.

func (*Recorder) Size

func (r *Recorder) Size() int64

Size is how many bytes the log file holds.

func (*Recorder) Started

func (r *Recorder) Started() time.Time

Started is when the log began.

Jump to

Keyboard shortcuts

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