Documentation
¶
Index ¶
- Constants
- func DebugPrintf(format string, v ...interface{})
- func DebugPrintln(v ...interface{})
- func Dump(v interface{})
- func ErrorPrintf(format string, v ...interface{})
- func ErrorPrintln(v ...interface{})
- func FatalPrintf(format string, v ...interface{})
- func FatalPrintln(v ...interface{})
- func GetSeverityLevel(levelName string) int8
- func GetSeverityName(level logLevel) string
- func InfoPrintf(format string, v ...interface{})
- func InfoPrintln(v ...interface{})
- func NewLogger(level logLevel, timeformat string, outflow io.Writer) *loggerT
- func SetSeverity(level interface{})
- func SetTimeformat(timeformat string)
- func WarnPrintf(format string, v ...interface{})
- func WarnPrintln(v ...interface{})
- type KafkaConfig
- type KafkaWriter
Constants ¶
const ( DEBUG logLevel = iota INFO WARN ERROR FATAL )
Log level constants
Variables ¶
This section is empty.
Functions ¶
func DebugPrintf ¶
func DebugPrintf(format string, v ...interface{})
DebugPrintf std Debug printf function
func Dump ¶ added in v0.0.6
func Dump(v interface{})
Dump std function to print structs, maps, slices, and arrays in a readable format.
func ErrorPrintf ¶
func ErrorPrintf(format string, v ...interface{})
ErrorPrintf std Error printf function
func FatalPrintf ¶
func FatalPrintf(format string, v ...interface{})
FatalPrintf std Fatal printf function
func GetSeverityLevel ¶
GetSeverityLevel Get the log level constant number value from level string
func GetSeverityName ¶
func GetSeverityName(level logLevel) string
GetSeverityName Convert the log level string to constant number value
func InfoPrintf ¶
func InfoPrintf(format string, v ...interface{})
InfoPrintf std Info printf function
func SetTimeformat ¶
func SetTimeformat(timeformat string)
SetTimeformat Set the time format within log
func WarnPrintf ¶
func WarnPrintf(format string, v ...interface{})
WarnPrintf std Warn printf function
Types ¶
type KafkaConfig ¶ added in v0.0.8
type KafkaConfig struct {
// Brokers contains bootstrap addresses in host:port form.
Brokers []string
// Topic must already exist in the Kafka cluster.
Topic string
// ClientID identifies the producer to the brokers.
ClientID string
// Timeout limits each publish operation. Zero uses ten seconds.
Timeout time.Duration
// Dial optionally opens raw broker connections, for example through a proxy.
// The transport performs TLS and SASL handshakes after Dial returns.
Dial func(context.Context, string, string) (net.Conn, error)
// TLS and SASLMechanism enable encrypted and authenticated connections.
TLS *tls.Config
SASLMechanism sasl.Mechanism
// OnError receives publish errors, including writes after Close. When nil,
// errors are printed to stderr. It may be called concurrently.
OnError func(error)
}
KafkaConfig configures a logger's Kafka output.
type KafkaWriter ¶ added in v0.0.8
type KafkaWriter struct {
// contains filtered or unexported fields
}
KafkaWriter publishes each nonempty Write as one Kafka record. Successful writes wait for all in-sync replicas to acknowledge the record. Use NewKafkaWriter to construct it and Close to release its connections.
func EnableKafka ¶ added in v0.0.8
func EnableKafka(config KafkaConfig) (*KafkaWriter, error)
EnableKafka configures Kafka output for the package's default logger.
func NewKafkaWriter ¶ added in v0.0.8
func NewKafkaWriter(config KafkaConfig) (*KafkaWriter, error)
NewKafkaWriter validates config and creates a synchronous Kafka writer. Connections are established on the first write, not during construction.
func (*KafkaWriter) Close ¶ added in v0.0.8
func (w *KafkaWriter) Close() error
Close waits for in-flight writes and releases the producer's connections. It is safe to call repeatedly or concurrently; later writes fail.