Documentation
¶
Index ¶
- Constants
- func ChildOutputField() zap.Field
- func CleanupTestWriter(file *os.File) error
- func CreateCLIUpstreamServerLogger(config *config.LogConfig, serverName string) (*zap.Logger, error)
- func CreateHTTPLogger(config *config.LogConfig) (*zap.Logger, error)
- func CreateRotatingWriteSyncer(config *config.LogConfig) (zapcore.WriteSyncer, error)
- func CreateTestWriter() (io.Writer, *os.File, error)
- func CreateUpstreamServerLogger(config *config.LogConfig, serverName string) (*zap.Logger, error)
- func DefaultLogConfig() *config.LogConfig
- func EnsureLogDir(logDir string) error
- func GetLogDir() (string, error)
- func GetLogFilePath(filename string) (string, error)
- func GetLogFilePathWithDir(logDir, filename string) (string, error)
- func NewUpstreamServerLogger(config *config.LogConfig, serverName string) (*zap.Logger, io.Closer, error)
- func ReadUpstreamServerLogTail(config *config.LogConfig, serverName string, lines int) ([]string, error)
- func ReadUpstreamServerLogTailAttributed(config *config.LogConfig, serverName string, lines int) ([]string, error)
- func RedactContainerMentions(s string) string
- func ServerLogFilename(serverName string) string
- func SetupCommandLogger(serverCommand bool, logLevel string, logToFile bool, logDir string) (*zap.Logger, error)
- func SetupLogger(config *config.LogConfig) (*zap.Logger, error)
- type LogDirInfo
- type LoggerInfo
- type SecretSanitizer
- func (s *SecretSanitizer) Check(entry zapcore.Entry, checkedEntry *zapcore.CheckedEntry) *zapcore.CheckedEntry
- func (s *SecretSanitizer) RegisterResolvedSecret(value string)
- func (s *SecretSanitizer) UnregisterResolvedSecret(value string)
- func (s *SecretSanitizer) With(fields []zapcore.Field) zapcore.Core
- func (s *SecretSanitizer) Write(entry zapcore.Entry, fields []zapcore.Field) error
Constants ¶
const ( LogLevelTrace = "trace" LogLevelDebug = "debug" LogLevelInfo = "info" LogLevelWarn = "warn" LogLevelError = "error" )
Log level constants
Variables ¶
This section is empty.
Functions ¶
func ChildOutputField ¶ added in v0.68.0
ChildOutputField stamps a record whose payload is a child process's own output (stderr lines, launcher-pumped stdout/stderr, docker CLI output). Every producer that writes child text into the per-server log — always as a field VALUE, never the message (rule 1) — attaches it, so the attributed reader can apply the child-output subject rule (rule 3).
func CleanupTestWriter ¶
CleanupTestWriter removes temporary test files
func CreateCLIUpstreamServerLogger ¶
func CreateCLIUpstreamServerLogger(config *config.LogConfig, serverName string) (*zap.Logger, error)
CreateCLIUpstreamServerLogger creates a logger for CLI debugging that outputs to console
func CreateHTTPLogger ¶
CreateHTTPLogger creates a logger specifically for HTTP API requests
func CreateRotatingWriteSyncer ¶ added in v0.23.0
func CreateRotatingWriteSyncer(config *config.LogConfig) (zapcore.WriteSyncer, error)
CreateRotatingWriteSyncer creates a rotation-backed file sink for a log config.
func CreateTestWriter ¶
CreateTestWriter creates a writer for testing that captures both file and memory output
func CreateUpstreamServerLogger ¶
CreateUpstreamServerLogger creates a logger for a specific upstream server. The caller cannot release its file sink; prefer NewUpstreamServerLogger wherever the logger has an owner with a teardown path.
func DefaultLogConfig ¶
DefaultLogConfig returns default logging configuration
func EnsureLogDir ¶
EnsureLogDir creates the log directory if it doesn't exist
func GetLogFilePath ¶
GetLogFilePath returns the full path for a log file in the standard log directory
func GetLogFilePathWithDir ¶
GetLogFilePathWithDir returns the full path for a log file in a custom log directory
func NewUpstreamServerLogger ¶ added in v0.66.1
func NewUpstreamServerLogger(config *config.LogConfig, serverName string) (*zap.Logger, io.Closer, error)
NewUpstreamServerLogger creates a logger for a specific upstream server and returns the closer of its file sink. Close it whenever the server is torn down or disconnected (issue #1266: an unclosed sink held one open handle per server for the life of the process, and on Windows pinned the file); a later write reopens the sink, so closing it on every disconnect is safe.
func ReadUpstreamServerLogTail ¶
func ReadUpstreamServerLogTail(config *config.LogConfig, serverName string, lines int) ([]string, error)
ReadUpstreamServerLogTail reads the last N lines from an upstream server log file
func ReadUpstreamServerLogTailAttributed ¶ added in v0.68.0
func ReadUpstreamServerLogTailAttributed(config *config.LogConfig, serverName string, lines int) ([]string, error)
ReadUpstreamServerLogTailAttributed reads the last N records of an upstream server log that are attributable to serverName (Spec 105 FR-007, research D8). Attribution is decided per record BEFORE the tail limit, so an interleaved co-owner record never displaces an attributable one from the returned window, and the returned length is the authorized tail length. Records with no accepted stamp, records stamped for another server and records failing the subject-evidence rule are withheld. Administrators use ReadUpstreamServerLogTail (whole file, byte-identical to pre-105).
The scan starts at scopedBackwardStartOffset, at most scopedBackwardReadBudget bytes before EOF (codex round 16 finding 2): scanning from byte 0 made a request's cost proportional to whatever a hidden co-owner had written earlier in this shared file — a response-time side channel disclosing its volume, which SC-005's non-disclosing-refusal definition (status, body AND timing class) forbids. Below the budget (the common case) this reads and returns exactly what a whole-file scan from byte 0 would; past it, a request whose own most recent `lines` records sit further back returns fewer than `lines` records rather than reading further — bounded and fail-closed, not incorrect. The append-ordering this relies on (newest records nearest EOF), the boundary/subject-evidence rules (readBoundedLine, recordAttributableTo) and the per-record cap are all unchanged; only where the scan starts is new.
func RedactContainerMentions ¶ added in v0.68.0
RedactContainerMentions blanks every container id, canonical container name and Docker name-conflict phrase in s. The MCP status surface (`upstream_servers` tail_log / list `connection_status.last_error`, and the health detail derived from it) renders a connect error that re-emits the child's stderr — on a `docker run` name collision that text names the colliding container, which belongs to another server (`a/b` and `a-b` generate the same name). A scoped caller gets the same redaction whether or not a co-owner exists (FR-007: uniform, non-disclosing); administrators see the text unchanged (SC-005).
func ServerLogFilename ¶ added in v0.38.0
ServerLogFilename is the exported accessor for the per-server log filename. Read sites outside this package (the REST/daemon log reader in internal/server and the no-daemon CLI file reader in cmd/mcpproxy) MUST derive the path through this helper so reads resolve to the same sanitized flat file the writers create for namespace/name registry servers (MCP-1111). Do not re-derive "server-%s.log" by hand at a call site.
func SetupCommandLogger ¶
func SetupCommandLogger(serverCommand bool, logLevel string, logToFile bool, logDir string) (*zap.Logger, error)
SetupCommandLogger creates a logger for console commands with appropriate default levels serverCommand: if true, uses INFO level by default; if false, uses WARN level by default
Types ¶
type LogDirInfo ¶
type LogDirInfo struct {
Path string `json:"path"`
OS string `json:"os"`
Description string `json:"description"`
Standard string `json:"standard"`
}
LogDirInfo returns information about the log directory for different OS
func GetLogDirInfo ¶
func GetLogDirInfo() (*LogDirInfo, error)
GetLogDirInfo returns detailed information about the log directory
type LoggerInfo ¶
type LoggerInfo struct {
LogDir string `json:"log_dir"`
LogFile string `json:"log_file"`
Level string `json:"level"`
EnableFile bool `json:"enable_file"`
EnableConsole bool `json:"enable_console"`
MaxSize int `json:"max_size"`
MaxBackups int `json:"max_backups"`
MaxAge int `json:"max_age"`
Compress bool `json:"compress"`
JSONFormat bool `json:"json_format"`
CreatedAt time.Time `json:"created_at"`
}
LoggerInfo represents information about the logger setup
func GetLoggerInfo ¶
func GetLoggerInfo(config *config.LogConfig) (*LoggerInfo, error)
GetLoggerInfo returns information about the current logger configuration
type SecretSanitizer ¶
SecretSanitizer wraps a zapcore.Core to sanitize sensitive values from logs
func NewSecretSanitizer ¶
func NewSecretSanitizer(core zapcore.Core) *SecretSanitizer
NewSecretSanitizer creates a new sanitizing core that wraps the provided core
func (*SecretSanitizer) Check ¶
func (s *SecretSanitizer) Check(entry zapcore.Entry, checkedEntry *zapcore.CheckedEntry) *zapcore.CheckedEntry
Check delegates to the wrapped core
func (*SecretSanitizer) RegisterResolvedSecret ¶
func (s *SecretSanitizer) RegisterResolvedSecret(value string)
RegisterResolvedSecret registers a secret value that was resolved from keyring/env so it can be masked in logs
func (*SecretSanitizer) UnregisterResolvedSecret ¶
func (s *SecretSanitizer) UnregisterResolvedSecret(value string)
UnregisterResolvedSecret removes a secret from the mask cache