Documentation
¶
Index ¶
- func CaptureStderr() error
- func Clean(msg string) string
- func Debug(msg string, kv ...any)
- func Error(msg string, kv ...any)
- func Fatal(msg string, kv ...any)
- func GetLevel() zapcore.Level
- func Info(msg string, kv ...any)
- func Panic(msg string, kv ...any)
- func SetLevel(level string) error
- func ToStderr()
- func ToStdout()
- func Warn(msg string, kv ...any)
- type LogEntry
- type RingBuffer
- func (rb *RingBuffer) Check(entry zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry
- func (rb *RingBuffer) Enabled(lvl zapcore.Level) bool
- func (rb *RingBuffer) Snapshot() []LogEntry
- func (rb *RingBuffer) Subscribe(ctx context.Context) <-chan LogEntry
- func (rb *RingBuffer) Sync() error
- func (rb *RingBuffer) With(fields []zapcore.Field) zapcore.Core
- func (rb *RingBuffer) Write(entry zapcore.Entry, fields []zapcore.Field) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureStderr ¶
func CaptureStderr() error
CaptureStderr redirects file descriptor 2 (stderr) through a pipe so that output from C libraries (e.g. libdqlite/libraft) is captured and routed through the structured logger instead of appearing as raw, colorized text.
The original stderr fd is preserved via dup so that fatal/crash output from the Go runtime still reaches the terminal.
func Debug ¶
Debug logs a debug message. Refer to: https://godoc.org/go.uber.org/zap for more details.
func Error ¶
Error logs an error message. Refer to: https://godoc.org/go.uber.org/zap for more details.
func Fatal ¶
Fatal logs a fatal message. Refer to: https://godoc.org/go.uber.org/zap for more details.
func Info ¶
Info logs an info message. Refer to: https://godoc.org/go.uber.org/zap for more details.
func Panic ¶
Panic logs a panic message. Refer to: https://godoc.org/go.uber.org/zap for more details.
func SetLevel ¶
SetLevel sets the log level by specifying a string which can be any of: ["DEBUG", "INFO", "WARNING", "ERROR", "PANIC", "FATAL"], case-insensitive.
func ToStderr ¶
func ToStderr()
ToStderr routes structured logs to stderr. CLI commands call this so that stdout carries only the command's machine-readable output (e.g. a `caesium receipt get` JSON receipt that gets piped into `caesium verify`). The server does NOT use this — it logs to stdout and captures C-library stderr separately (see CaptureStderr), where routing logs to stderr would feed the capture pipe back into the logger.
func ToStdout ¶
func ToStdout()
ToStdout routes structured logs to stdout (the server default). Used to restore stdout logging before the server installs its stderr capture.
func Warn ¶
Warn logs a warning message. Refer to: https://godoc.org/go.uber.org/zap for more details.
Types ¶
type LogEntry ¶
type LogEntry struct {
Sequence uint64 `json:"sequence"`
Timestamp time.Time `json:"ts"`
Level string `json:"level"`
Message string `json:"msg"`
Caller string `json:"caller,omitempty"`
Fields json.RawMessage `json:"fields,omitempty"`
}
LogEntry is a single structured log record stored in the ring buffer.
type RingBuffer ¶
type RingBuffer struct {
// contains filtered or unexported fields
}
RingBuffer is a bounded, thread-safe circular buffer of log entries that also implements zapcore.Core so it can be tee'd alongside the primary stdout core.
func NewRingBuffer ¶
func NewRingBuffer(size int, level zapcore.Level) *RingBuffer
NewRingBuffer creates a ring buffer that stores up to size entries.
func (*RingBuffer) Check ¶
func (rb *RingBuffer) Check(entry zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry
func (*RingBuffer) Snapshot ¶
func (rb *RingBuffer) Snapshot() []LogEntry
Snapshot returns a copy of all buffered entries in chronological order.
func (*RingBuffer) Subscribe ¶
func (rb *RingBuffer) Subscribe(ctx context.Context) <-chan LogEntry
Subscribe returns a channel that receives live log entries. The channel is closed when ctx is cancelled. Sends are non-blocking; entries are dropped if the subscriber cannot keep up.
func (*RingBuffer) Sync ¶
func (rb *RingBuffer) Sync() error