Documentation ¶
Index ¶
- Constants
- Variables
- type ConsoleLogger
- func (dl *ConsoleLogger) Critical(message interface{}, params ...interface{})
- func (dl *ConsoleLogger) Debug(message interface{}, params ...interface{})
- func (dl *ConsoleLogger) Error(message interface{}, params ...interface{})
- func (dl *ConsoleLogger) Info(message interface{}, params ...interface{})
- func (dl *ConsoleLogger) Trace(message interface{}, params ...interface{})
- func (dl *ConsoleLogger) Warn(message interface{}, params ...interface{})
- type KafkaLogEmitter
- func (k *KafkaLogEmitter) Close()
- func (k *KafkaLogEmitter) Critical(message interface{}, params ...interface{})
- func (k *KafkaLogEmitter) Debug(message interface{}, params ...interface{})
- func (k *KafkaLogEmitter) Emit(logLine *avro.LogLine)
- func (k *KafkaLogEmitter) Error(message interface{}, params ...interface{})
- func (k *KafkaLogEmitter) Info(message interface{}, params ...interface{})
- func (k *KafkaLogEmitter) Trace(message interface{}, params ...interface{})
- func (k *KafkaLogEmitter) Warn(message interface{}, params ...interface{})
- func (k *KafkaLogEmitter) Write(bytes []byte) (int, error)
- type KafkaLogEmitterConfig
- type Log
- type LogEmitter
- type LogLevel
- type NoopEmitter
Constants ¶
const ( /* Logtypeid field value for LogLine indicating Trace log level */ TraceLogTypeId int64 = 1 /* Logtypeid field value for LogLine indicating Debug log level */ DebugLogTypeId int64 = 2 /* Logtypeid field value for LogLine indicating Info log level */ InfoLogTypeId int64 = 3 /* Logtypeid field value for LogLine indicating Warn log level */ WarnLogTypeId int64 = 4 /* Logtypeid field value for LogLine indicating Error log level */ ErrorLogTypeId int64 = 5 /* Logtypeid field value for LogLine indicating Critical log level */ CriticalLogTypeId int64 = 6 )
Variables ¶
var DefaultLogFormat string = "%Date/%Time [%LEVEL] %Msg%n"
var Logger = NewDefaultLogger()
Functions ¶
This section is empty.
Types ¶
type ConsoleLogger ¶
type ConsoleLogger struct {
// contains filtered or unexported fields
}
ConsoleLogger is an implementation of Log interface that outputs to console.
func NewConsoleLogger ¶
func NewConsoleLogger(level LogLevel, format string) *ConsoleLogger
NewConsoleLogger creates a new ConsoleLogger that is configured to write messages to console with given minimum log level and given message format.
func (*ConsoleLogger) Critical ¶
func (dl *ConsoleLogger) Critical(message interface{}, params ...interface{})
Critical formats a given message according to given params to log with level Critical.
func (*ConsoleLogger) Debug ¶
func (dl *ConsoleLogger) Debug(message interface{}, params ...interface{})
Debug formats a given message according to given params to log with level Debug.
func (*ConsoleLogger) Error ¶
func (dl *ConsoleLogger) Error(message interface{}, params ...interface{})
Error formats a given message according to given params to log with level Error.
func (*ConsoleLogger) Info ¶
func (dl *ConsoleLogger) Info(message interface{}, params ...interface{})
Info formats a given message according to given params to log with level Info.
func (*ConsoleLogger) Trace ¶
func (dl *ConsoleLogger) Trace(message interface{}, params ...interface{})
Trace formats a given message according to given params to log with level Trace.
func (*ConsoleLogger) Warn ¶
func (dl *ConsoleLogger) Warn(message interface{}, params ...interface{})
Warn formats a given message according to given params to log with level Warn.
type KafkaLogEmitter ¶
type KafkaLogEmitter struct {
// contains filtered or unexported fields
}
KafkaLogEmitter implements LogEmitter and KafkaLogger and sends all structured log data to a Kafka topic encoded as Avro.
func NewKafkaLogEmitter ¶
func NewKafkaLogEmitter(config *KafkaLogEmitterConfig) (*KafkaLogEmitter, error)
NewKafkaLogEmitter creates a new KafkaLogEmitter with a provided configuration.
func (*KafkaLogEmitter) Close ¶
func (k *KafkaLogEmitter) Close()
Close closes the underlying producer. The KafkaLogEmitter won't be usable anymore after call to this.
func (*KafkaLogEmitter) Critical ¶
func (k *KafkaLogEmitter) Critical(message interface{}, params ...interface{})
Critical formats a given message according to given params to log with level Critical and produces to a given Kafka topic.
func (*KafkaLogEmitter) Debug ¶
func (k *KafkaLogEmitter) Debug(message interface{}, params ...interface{})
Debug formats a given message according to given params to log with level Debug and produces to a given Kafka topic.
func (*KafkaLogEmitter) Emit ¶
func (k *KafkaLogEmitter) Emit(logLine *avro.LogLine)
Emit emits a single entry to a given destination topic.
func (*KafkaLogEmitter) Error ¶
func (k *KafkaLogEmitter) Error(message interface{}, params ...interface{})
Error formats a given message according to given params to log with level Error and produces to a given Kafka topic.
func (*KafkaLogEmitter) Info ¶
func (k *KafkaLogEmitter) Info(message interface{}, params ...interface{})
Info formats a given message according to given params to log with level Info and produces to a given Kafka topic.
func (*KafkaLogEmitter) Trace ¶
func (k *KafkaLogEmitter) Trace(message interface{}, params ...interface{})
Trace formats a given message according to given params to log with level Trace and produces to a given Kafka topic.
func (*KafkaLogEmitter) Warn ¶
func (k *KafkaLogEmitter) Warn(message interface{}, params ...interface{})
Warn formats a given message according to given params to log with level Warn and produces to a given Kafka topic.
type KafkaLogEmitterConfig ¶
type KafkaLogEmitterConfig struct { // LogLevel to use for KafkaLogEmitter LogLevel LogLevel // LogLine event source. Used only when called as a Logger interface. Source string // LogLine tags. Used only when called as a logger interface. Tags map[string]string // Topic to emit logs to. Topic string // Confluent Avro schema registry URL. SchemaRegistryUrl string // Producer config that will be used by this emitter ProducerConfig *producer.ProducerConfig // Siesta connector config that will be used by this emitter ConnectorConfig *siesta.ConnectorConfig // ProducerCloseTimeout is the maximum time to wait until the producer closes gracefully ProducerCloseTimeout time.Duration }
KafkaLogEmitterConfig provides multiple configuration entries for KafkaLogEmitter.
func NewKafkaLogEmitterConfig ¶
func NewKafkaLogEmitterConfig() *KafkaLogEmitterConfig
NewKafkaLogEmitterConfig creates a new KafkaLogEmitterConfig with log level set to Info.
type Log ¶
type Log interface { //Formats a given message according to given params to log with level Trace. Trace(message interface{}, params ...interface{}) //Formats a given message according to given params to log with level Debug. Debug(message interface{}, params ...interface{}) //Formats a given message according to given params to log with level Info. Info(message interface{}, params ...interface{}) //Formats a given message according to given params to log with level Warn. Warn(message interface{}, params ...interface{}) //Formats a given message according to given params to log with level Error. Error(message interface{}, params ...interface{}) //Formats a given message according to given params to log with level Critical. Critical(message interface{}, params ...interface{}) }
Log is a logger interface. Lets you plug-in your custom logging library instead of using built-in one.
func NewDefaultLogger ¶
func NewDefaultLogger() Log
type LogEmitter ¶
type LogEmitter interface { // Emit sends a single LogLine to some destination. Emit(*avro.LogLine) // Close closes the given emitter. Close() }
LogEmitter is an interface that handles structured log data.
type LogLevel ¶
type LogLevel string
LogLevel represents a logging level.
const ( // TraceLevel is used for debugging to find problems in functions, variables etc. TraceLevel LogLevel = "trace" // DebugLevel is used for detailed system reports and diagnostic messages. DebugLevel LogLevel = "debug" // InfoLevel is used for general information about a running application. InfoLevel LogLevel = "info" // WarnLevel is used to indicate small errors and failures that should not happen normally but are recovered automatically. WarnLevel LogLevel = "warn" // ErrorLevel is used to indicate severe errors that affect application workflow and are not handled automatically. ErrorLevel LogLevel = "error" // CriticalLevel is used to indicate fatal errors that may cause data corruption or loss. CriticalLevel LogLevel = "critical" )
type NoopEmitter ¶
type NoopEmitter struct{}
EmptyEmitter implements emitter and ignores all incoming messages. Used not to break anyone.
func NewEmptyEmitter ¶
func NewEmptyEmitter() *NoopEmitter
NewEmptyEmitter creates a new EmptyEmitter.
func (*NoopEmitter) Emit ¶
func (e *NoopEmitter) Emit(*avro.LogLine)
Does nothing. Ignores given message.