...

Source file src/github.com/emicklei/go-restful/v3/log/log.go

Documentation: github.com/emicklei/go-restful/v3/log

     1  package log
     2  
     3  import (
     4  	stdlog "log"
     5  	"os"
     6  )
     7  
     8  // StdLogger corresponds to a minimal subset of the interface satisfied by stdlib log.Logger
     9  type StdLogger interface {
    10  	Print(v ...interface{})
    11  	Printf(format string, v ...interface{})
    12  }
    13  
    14  var Logger StdLogger
    15  
    16  func init() {
    17  	// default Logger
    18  	SetLogger(stdlog.New(os.Stderr, "[restful] ", stdlog.LstdFlags|stdlog.Lshortfile))
    19  }
    20  
    21  // SetLogger sets the logger for this package
    22  func SetLogger(customLogger StdLogger) {
    23  	Logger = customLogger
    24  }
    25  
    26  // Print delegates to the Logger
    27  func Print(v ...interface{}) {
    28  	Logger.Print(v...)
    29  }
    30  
    31  // Printf delegates to the Logger
    32  func Printf(format string, v ...interface{}) {
    33  	Logger.Printf(format, v...)
    34  }
    35  

View as plain text