2019-11-08 21:45:10 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/canonical/go-dqlite/internal/logging"
|
|
|
|
)
|
|
|
|
|
|
|
|
// LogFunc is a function that can be used for logging.
|
|
|
|
type LogFunc = logging.Func
|
|
|
|
|
|
|
|
// LogLevel defines the logging level.
|
|
|
|
type LogLevel = logging.Level
|
|
|
|
|
|
|
|
// Available logging levels.
|
|
|
|
const (
|
|
|
|
LogDebug = logging.Debug
|
|
|
|
LogInfo = logging.Info
|
|
|
|
LogWarn = logging.Warn
|
|
|
|
LogError = logging.Error
|
|
|
|
)
|
|
|
|
|
2019-12-16 18:45:21 +00:00
|
|
|
var (
|
|
|
|
logger = log.New(os.Stdout, "", log.LstdFlags|log.Lmicroseconds)
|
|
|
|
)
|
|
|
|
|
2019-11-08 21:45:10 +00:00
|
|
|
// DefaultLogFunc emits messages using the stdlib's logger.
|
|
|
|
func DefaultLogFunc(l LogLevel, format string, a ...interface{}) {
|
2019-12-16 18:45:21 +00:00
|
|
|
logger.Output(2, fmt.Sprintf("[%s]: %s", l.String(), fmt.Sprintf(format, a...)))
|
2019-11-08 21:45:10 +00:00
|
|
|
}
|