go-proxy/log/access.go
Virgil ecd4130457 docs(proxy): sharpen AX examples
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-05 01:52:20 +00:00

25 lines
750 B
Go

// Package log implements append-only access and share logging for the proxy.
//
// al, result := log.NewAccessLog("/var/log/proxy-access.log")
// bus.Subscribe(proxy.EventLogin, al.OnLogin)
// bus.Subscribe(proxy.EventClose, al.OnClose)
package log
import (
"os"
"sync"
)
// AccessLog writes connection lifecycle lines to an append-only text file.
//
// Line format (connect): 2026-04-04T12:00:00Z CONNECT <ip> <user> <agent>
// Line format (close): 2026-04-04T12:00:00Z CLOSE <ip> <user> rx=<bytes> tx=<bytes>
//
// al := log.NewAccessLog("/var/log/proxy-access.log")
// bus.Subscribe(proxy.EventLogin, al.OnLogin)
// bus.Subscribe(proxy.EventClose, al.OnClose)
type AccessLog struct {
path string
mu sync.Mutex
file *os.File
}