Documentation
¶
Overview ¶
Package stdlogimpl contains stdlib logger implementation of Logger interface.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLogger ¶
NewLogger creates a new log.Logger from the provided stdlog.Logger. It prints the provided fields in "key=value" form after the message. NOTE: The prefix of a standard logger is used to print the logging level, so setting it before calling NewLogger will have no effect.
Example ¶
package main
import (
stdlog "log"
"os"
"github.com/junk1tm/log"
"github.com/junk1tm/log/stdlogimpl"
)
func main() {
// configure stdlog logger here:
sl := stdlog.New(os.Stdout, "", 0)
logger := stdlogimpl.NewLogger(sl)
logger.Debug("example 1", log.Int("foo", 1))
logger.Info("example 2", log.Int("bar", 2))
logger.Error("example 3", log.Int("baz", 3))
}
Output: [DEBUG] example 1 foo=1 [INFO] example 2 bar=2 [ERROR] example 3 baz=3
func Unwrap ¶ added in v0.2.0
Unwrap unwraps the provided logger, allowing access to the underlying stdlog.Logger. It returns true on success, false otherwise.
Example ¶
package main
import (
stdlog "log"
"os"
"github.com/junk1tm/log/stdlogimpl"
)
func main() {
sl := stdlog.New(os.Stdout, "", 0)
logger := stdlogimpl.NewLogger(sl)
if _, ok := stdlogimpl.Unwrap(logger); ok {
// use stdlog logger here:
}
}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.