github.com/petermattis/pebble@v0.0.0-20190905164901-ab51a2166067/internal/base/logger.go (about)

     1  // Copyright 2011 The LevelDB-Go and Pebble Authors. All rights reserved. Use
     2  // of this source code is governed by a BSD-style license that can be found in
     3  // the LICENSE file.
     4  
     5  package base
     6  
     7  import (
     8  	"fmt"
     9  	"log"
    10  	"os"
    11  )
    12  
    13  // Logger defines an interface for writing log messages.
    14  type Logger interface {
    15  	Infof(format string, args ...interface{})
    16  	Fatalf(format string, args ...interface{})
    17  }
    18  
    19  type defaultLogger struct{}
    20  
    21  func (defaultLogger) Infof(format string, args ...interface{}) {
    22  	_ = log.Output(2, fmt.Sprintf(format, args...))
    23  }
    24  
    25  func (defaultLogger) Fatalf(format string, args ...interface{}) {
    26  	_ = log.Output(2, fmt.Sprintf(format, args...))
    27  	os.Exit(1)
    28  }