log

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 0 Imported by: 1 module, 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 log defines the optional diagnostic output used by shared XOps code. It does not inspect terminals or install a process-wide logger.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiagnosticEnabled added in v0.15.0

func DiagnosticEnabled(observer DiagnosticObserver, level int) bool

DiagnosticEnabled supports an optional DiagnosticLevel() int capability. Observers without it accept all levels. Producers can avoid expensive metadata decoding when their observer has selected a lower verbosity.

func EmitDiagnostic added in v0.15.0

func EmitDiagnostic(observer DiagnosticObserver, event Diagnostic)

EmitDiagnostic does nothing when no observer is installed.

Types

type DebugLogger

type DebugLogger interface {
	Debug(msg string, args ...any)
	Debugf(format string, args ...any)
}

DebugLogger implementations must be safe for concurrent calls.

var NopLogger DebugLogger = nopLogger{}

NopLogger discards diagnostic output without acquiring resources.

type Diagnostic added in v0.15.0

type Diagnostic struct {
	// Level is 1..3; zero preserves the original DEBUG1 event behavior.
	Level                                      int
	Kind                                       DiagnosticKind
	NodeID, Host, User                         string
	Port                                       int
	Proxied                                    bool
	Accepted                                   bool
	ClientVersion, ServerVersion               string
	KeyExchange, HostKey, Fingerprint          string
	ReadCipher, WriteCipher, ReadMAC, WriteMAC string
	Method                                     string
	Methods                                    []string
	StreamID                                   uint64
	Direction                                  string
	PacketType                                 uint8
	PacketID, PacketLength, ProtocolVersion    uint32
	StatusCode                                 uint32
	HasPacketID                                bool
	HasStatus                                  bool
	HasExitCode                                bool
	ExitCode                                   int64
	Attempt                                    int // Privilege exchange/password attempt, 1-based; zero when not applicable.
	Path, Extension, ExtensionVersion          string
	Truncated                                  bool
	Operation, Outcome                         string
	// PrivilegeCommand is a payload-redacted invocation, never a user command.
	// Prompts/patterns exclude response bytes and normalize random markers.
	PrivilegeCommand, PrivilegePrompt, PrivilegePromptPattern string
	Source, Destination                                       string
	Size                                                      int64
}

Diagnostic contains public protocol and redacted privilege metadata only. Never put credentials, private keys, file contents, or arbitrary error text in these fields. For AuthenticationAttempt, Method is the selected protocol method, not proof of success. For Authenticated, Method is the final successful method and Methods is the server-confirmed partial-success chain plus that final method. AuthenticationMethods uses Methods for the server's advertised alternatives.

type DiagnosticKind added in v0.15.0

type DiagnosticKind string

DiagnosticKind identifies an observed SSH/SFTP lifecycle transition.

const (
	Connecting            DiagnosticKind = "connecting"
	Connected             DiagnosticKind = "connected"
	ConnectionReused      DiagnosticKind = "connection_reused"
	HandshakeFailed       DiagnosticKind = "handshake_failed"
	HostKeyChecked        DiagnosticKind = "host_key_checked"
	AuthenticationMethods DiagnosticKind = "authentication_methods"
	AuthenticationAttempt DiagnosticKind = "authentication_attempt"
	Authenticated         DiagnosticKind = "authenticated"
	Negotiated            DiagnosticKind = "negotiated"
	SessionRequest        DiagnosticKind = "session_request"
	SessionStarted        DiagnosticKind = "session_started"
	SessionFinished       DiagnosticKind = "session_finished"
	SessionCleanup        DiagnosticKind = "session_cleanup"
	ForwardLifecycle      DiagnosticKind = "forward_lifecycle"
	PrivilegeLifecycle    DiagnosticKind = "privilege_lifecycle"
	SubsystemStarting     DiagnosticKind = "subsystem_starting"
	SubsystemReady        DiagnosticKind = "subsystem_ready"
	SubsystemFailed       DiagnosticKind = "subsystem_failed"
	SFTPVersion           DiagnosticKind = "sftp_version"
	SFTPExtension         DiagnosticKind = "sftp_extension"
	SFTPOperation         DiagnosticKind = "sftp_operation"
	SFTPPacket            DiagnosticKind = "sftp_packet"
	SFTPMalformed         DiagnosticKind = "sftp_malformed"
	SubsystemStderr       DiagnosticKind = "subsystem_stderr"
	FileTransfer          DiagnosticKind = "file_transfer"
)

type DiagnosticObserver added in v0.15.0

type DiagnosticObserver interface{ ObserveDiagnostic(Diagnostic) }

DiagnosticObserver is optional and independent of DebugLogger. Implementations must be concurrency-safe and return promptly (for example, enqueue into a bounded buffer). They must not alter authorization or protocol behavior. The caller owns the observer and keeps it alive until its connector/clients have closed. A nil observer disables all events.

Jump to

Keyboard shortcuts

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