Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FluentLogger ¶
type FluentLogger struct {
// contains filtered or unexported fields
}
FluentLogger is an implementation of Logger that writes a given string to a configured fluent address. It is not thread safe.
func NewFluentLogger ¶
func NewFluentLogger(network, addr, tag, stream string, extra map[string]string) *FluentLogger
NewFluentLogger instantiates a new FluentLogger. Note that it does not automatically connect the logger. Therefore, FluentLogger.Connect should be called before any calls to FluentLogger.Log.
func (*FluentLogger) Connect ¶
func (w *FluentLogger) Connect() error
func (*FluentLogger) Disconnect ¶
func (w *FluentLogger) Disconnect() error
func (*FluentLogger) IsConnected ¶
func (w *FluentLogger) IsConnected() bool
func (*FluentLogger) Log ¶
func (w *FluentLogger) Log(msg string) error
Log sends a given string as a message to the fluent address this logger is connected to. If the logger is not connected for some reason, call Connect first.
type Forwarder ¶
type Forwarder struct {
// contains filtered or unexported fields
}
Forwarder forwards messages from some source reader (typically a read-only fd from an os.Pipe) to some destination fluentWriter.
func NewForwarder ¶
NewForwarder returns a new Forwarder based on an input stream and a fluent destination. If there is an error connecting to the fluent destination, no error is returned and Forwarder.writer is set to nil. Then the connection will be retried on each successive call for Forwarder.Forward, and Forwarder.writer will be set once the connection is successful.
func (*Forwarder) Forward ¶
func (f *Forwarder) Forward()
Forward forwards log messages by launching two goroutines - one to read messages (line by line) from the configured reader, and one to write messages to the configured Logger. It returns immediately after launching these goroutines. The reader goroutine passes messages to the writer goroutine via a buffered channel. The channel's buffer length is determined by the Forwarder's bufLen property. Note that if the buffer is full, messages are unceremoniously dropped. Also note that if the underlying logger connection is not established, the Logger connection will be retried on each message until it can be successfully established. If the connection can't be established while processing a particular message, that message will be dropped. If there is an error during the Logger.Log call, it will be ignored (but the error will be writen to stderr) and the log message will likely be lost as well. Additionally, in the case of errors to Logger.Log, the Logger's connection is explicitly disconnected and retried on the next message for resiliency.
type Logger ¶
type Logger interface {
// Log writes the given message to the destination.
Log(msg string) error
// Connect establishes the Logger's connection to the destination.
Connect() error
// Disconnect breaks the connection to the destination. If there is no
// connection, Disconnect should be a no-op.
Disconnect() error
// IsConnected returns true if the Logger has an established connection.
IsConnected() bool
}
Logger is the interface that represents a type that writes log messages to some (remote) destination which requires a connection.
type MockLogger ¶
MockLogger is an autogenerated mock type for the Logger type
func NewMockLogger ¶
func NewMockLogger(t interface {
mock.TestingT
Cleanup(func())
}) *MockLogger
NewMockLogger creates a new instance of MockLogger. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockLogger) Connect ¶
func (_m *MockLogger) Connect() error
Connect provides a mock function with given fields:
func (*MockLogger) Disconnect ¶
func (_m *MockLogger) Disconnect() error
Disconnect provides a mock function with given fields:
func (*MockLogger) IsConnected ¶
func (_m *MockLogger) IsConnected() bool
IsConnected provides a mock function with given fields:
func (*MockLogger) Log ¶
func (_m *MockLogger) Log(msg string) error
Log provides a mock function with given fields: msg