Documentation
¶
Overview ¶
Package sink defines the final destinations for processed log messages. It supports multiple output types like the terminal console and physical files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsoleSink ¶
type ConsoleSink struct {
// contains filtered or unexported fields
}
ConsoleSink writes formatted log messages directly to standard output (Stdout).
func NewConsoleSink ¶
func NewConsoleSink(f formatter.Formatter) *ConsoleSink
NewConsoleSink creates a new ConsoleSink with the specified formatter.
func (*ConsoleSink) Close ¶
func (s *ConsoleSink) Close() error
Close is a no-op for the console sink.
func (*ConsoleSink) Write ¶
func (s *ConsoleSink) Write(msg types.LogMessage) error
Write outputs the message to the console.
type FileSink ¶
type FileSink struct {
// contains filtered or unexported fields
}
FileSink persists log messages to a physical file on disk.
func NewFileSink ¶
NewFileSink opens or creates a file at the specified path for appending logs.
type MultiSink ¶
type MultiSink struct {
// contains filtered or unexported fields
}
MultiSink allows broadcasting a single log message to multiple destinations. This is used when logs need to be simultaneously printed to the screen and persisted to a file.
func NewMultiSink ¶
NewMultiSink creates a composite sink from a variadic list of sinks.
type Sink ¶
type Sink interface {
// Write formats and delivers the log message to the underlying destination.
Write(msg types.LogMessage) error
// Close performs any necessary cleanup (e.g., closing file handles).
Close() error
}
Sink defines the contract for any component that serves as a final destination for log messages. Sinks are responsible for the physical writing of formatted strings to their respective backends.