Files
reproxy/examples/plugin/vendor/github.com/go-pkgz/lgr/interface.go
Umputun 7139c57766 RPC plugins support (#85)
* wip

* resolve merge artifacts

* full coverage for conductor

* wire plugin conductor to main and proxy

* wip, with separate match handler

* split matching logic with another handler, add initial docs

* move parts of proxy to handlers, add tests

* add headers in to be sent to proxied url

* merged from master

* add example with docker compose

* supress excesive debug reporting 0-9 disabled in docker

* add plugin tests

* randomize test port

* lint: minor warns

* lint: err shadow
2021-06-01 02:56:39 -05:00

49 lines
1.2 KiB
Go

package lgr
import (
stdlog "log"
)
var def = New() // default logger doesn't allow DEBUG and doesn't add caller info
// L defines minimal interface used to log things
type L interface {
Logf(format string, args ...interface{})
}
// Func type is an adapter to allow the use of ordinary functions as Logger.
type Func func(format string, args ...interface{})
// Logf calls f(format, args...)
func (f Func) Logf(format string, args ...interface{}) { f(format, args...) }
// NoOp logger
var NoOp = Func(func(format string, args ...interface{}) {})
// Std logger sends to std default logger directly
var Std = Func(func(format string, args ...interface{}) { stdlog.Printf(format, args...) })
// Printf simplifies replacement of std logger
func Printf(format string, args ...interface{}) {
def.logf(format, args...)
}
// Print simplifies replacement of std logger
func Print(line string) {
def.logf(line)
}
// Fatalf simplifies replacement of std logger
func Fatalf(format string, args ...interface{}) {
def.logf(format, args...)
def.fatal()
}
// Setup default logger with options
func Setup(opts ...Option) {
def = New(opts...)
}
// Default returns pre-constructed def logger (debug off, callers disabled)
func Default() L { return def }