Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

struct libtmux-go latest

CommandObserver

CommandObserver receives one CommandTrace per tmux command a Server and the values derived from it run:

Source and package
Qualified name
tmux.CommandObserver
Package
tmux
Distribution
github.com/libtmux/libtmux-go/tmux
Source
tmux/observer.go
struct tmux.CommandObserver

Description#

server, err := tmux.NewServer(tmux.ServerOptions{
CommandObserver: func(trace tmux.CommandTrace) {
slog.Info("tmux", "command", trace.Subcommand,
"transport", trace.Transport.String(),
"duration", trace.Duration, "exit", trace.ExitCode)
},
})
if err != nil {
log.Fatal(err)
}

It is called synchronously on the goroutine that ran the command, after the command finishes and before its result is returned, so a slow observer slows every command. Operations may invoke it concurrently; synchronize shared state. A nil observer costs nothing, not even the clock reads.

It sees the version probes this package runs on its own behalf, and the identity probe a daemon guard runs to decide whether a failure was a replaced daemon, so one call can produce more than one trace.

Esc

Type to search.

Reference previewOpen reference