CommandObserver
CommandObserver receives one CommandTrace per tmux command a Server and the values derived from it run:
Source and package
- Qualified name
-
tmux.Command Observer - Package
- tmux
- Distribution
- github.com/libtmux/libtmux-go/tmux
- Source
- tmux/observer.go
-
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.