gitee.com/mirrors_u-root/u-root@v7.0.0+incompatible/pkg/ulog/log.go (about)

     1  // Copyright 2019 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package ulog exposes logging via a Go interface.
     6  //
     7  // ulog has three implementations of the Logger interface: a Go standard
     8  // library "log" package Logger, a kernel syslog (dmesg) Logger, and a test
     9  // Logger that logs via a test's testing.TB.Logf.
    10  // To use the test logger import "ulog/ulogtest".
    11  package ulog
    12  
    13  import (
    14  	"log"
    15  	"os"
    16  )
    17  
    18  // Logger is a log receptacle.
    19  //
    20  // It puts your information somewhere for safekeeping.
    21  type Logger interface {
    22  	Printf(format string, v ...interface{})
    23  	Print(v ...interface{})
    24  }
    25  
    26  // Log is a Logger that prints to stderr, like the default log package.
    27  var Log Logger = log.New(os.Stderr, "", log.LstdFlags)
    28  
    29  type emptyLogger struct{}
    30  
    31  func (emptyLogger) Printf(format string, v ...interface{}) {}
    32  func (emptyLogger) Print(v ...interface{})                 {}
    33  
    34  // Null is a logger that prints nothing.
    35  var Null Logger = emptyLogger{}