Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver interface { Send(l *Entry) // PreLog returns a function that is called before each logging call // is made. This is only useful if the driver needs to find out the // caller and has a way of skipping some of the caller with a helper // function like `testing.T`.Helper(). Since the logger itself will get // information about the caller into log entries this is usually // unnecessary, so the function may return nil. // // An example of a driver that needs this helper is `logtotest`, which // sends log messages to a `testing.T` object, allowing the logged // data to be shown as part of the test, and automatically failing tests // that produce an error log. This loggers return `t.Helper`, and as // a result, the test log messages will point to the code that called // the logger, not to the log library itself. PreLog() func() }
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) D ¶
D sends a debug log message. This function is designed to allow close-to-nil overhead for debug log messages when the debug log is disabled.
Usage:
logger.D(func(lg log.DebugFn){ msg := computeSomethingExpensive() lg(msg) })
Since the callback function will not be executed if debug level is not enabled, its cost can be avoided in production, while still keeping the ability of debugging issues when they happen.
type Option ¶
type Option func(*options)
func WithDebugEnabledFn ¶
WithDebugEnabledFn allows providing a function that will be invoked to determine if debug log messages should be logged. Might be called concurrently, and must be fast.
func WithPrefix ¶
WithPrefix can be used on a logger to configure it to include a prefix on all messages.
If the prefix is "Foo" and a message "Bar" is send to a log, then the resulting log message will be "Foo: Bar".
func WithString ¶
Directories ¶
Path | Synopsis |
---|---|
Package niltarget is a log driver that does nothing, dropping all messages.
|
Package niltarget is a log driver that does nothing, dropping all messages. |
Package testtarget is a log driver that sends log messages to a go test.
|
Package testtarget is a log driver that sends log messages to a go test. |
Package texttarget is a log driver that encodes log messages as text and writes log messages to a provided writer.
|
Package texttarget is a log driver that encodes log messages as text and writes log messages to a provided writer. |