34 lines
849 B
Go
34 lines
849 B
Go
// Copyright 2011 The LevelDB-Go and Pebble Authors. All rights reserved. Use
|
|
// of this source code is governed by a BSD-style license that can be found in
|
|
// the LICENSE file.
|
|
|
|
package pebble
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
// Logger defines an interface for writing log messages.
|
|
type Logger interface {
|
|
Infof(format string, args ...interface{})
|
|
Fatalf(format string, args ...interface{})
|
|
}
|
|
|
|
type defaultLogger struct{}
|
|
|
|
// DefaultLogger logs to the Go stdlib logs.
|
|
var DefaultLogger defaultLogger
|
|
|
|
// Infof implements the Logger.Infof interface.
|
|
func (defaultLogger) Infof(format string, args ...interface{}) {
|
|
_ = log.Output(2, fmt.Sprintf(format, args...))
|
|
}
|
|
|
|
// Fatalf implements the Logger.Fatalf interface.
|
|
func (defaultLogger) Fatalf(format string, args ...interface{}) {
|
|
_ = log.Output(2, fmt.Sprintf(format, args...))
|
|
os.Exit(1)
|
|
}
|