func Error(args ...interface{}) {
	baseLogger.sourced().Error(args...)
}
Error logs a message at level Error on the standard logger.
package log
import (
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net/url"
	"os"
	"runtime"
	"strconv"
	"strings"
	"github.com/sirupsen/logrus"
	"gopkg.in/alecthomas/kingpin.v2"
)
var setSyslogFormatter func(logger, string, string) error
var setEventlogFormatter func(logger, string, bool) error
func setJSONFormatter() {
	origLogger.Formatter = &logrus.JSONFormatter{}
}
type loggerSettings struct {
	level  string
	format string
}
func (s *loggerSettings) apply(ctx *kingpin.ParseContext) error {
	err := baseLogger.SetLevel(s.level)
	if err != nil {
		return err
	}
	err = baseLogger.SetFormat(s.format)
	return err
}
func AddFlags(a *kingpin.Application) {
	s := loggerSettings{}
	a.Flag("log.level", "Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal]").
		Default(origLogger.Level.String()).
		StringVar(&s.level)
	defaultFormat := url.URL{Scheme: "logger", Opaque: "stderr"}
	a.Flag("log.format", `Set the log target and format. Example: "logger:syslog?appname=bob&local=7" or "logger:stdout?json=true"`).
		Default(defaultFormat.String()).
		StringVar(&s.format)
	a.Action(s.apply)
}
type Logger interface {
	Debug(...interface{})
	Debugln(...interface{})
	Debugf(string, ...interface{})
	Info(...interface{})
	Infoln(...interface{})
	Infof(string, ...interface{})
	Warn(...interface{})
	Warnln(...interface{})
	Warnf(string, ...interface{})
	Error(...interface{})
	Errorln(...interface{})
	Errorf(string, ...interface{})
	Fatal(...interface{})
	Fatalln(...interface{})
	Fatalf(string, ...interface{})
	With(key string, value interface{}) Logger
	SetFormat(string) error
	SetLevel(string) error
}
type logger struct {
	entry *logrus.Entry
}
func (l logger) With(key string, value interface{}) Logger {
	return logger{l.entry.WithField(key, value)}
}
func (l logger) Debug(args ...interface{}) {
	l.sourced().Debug(args...)
}
func (l logger) Debugln(args ...interface{}) {
	l.sourced().Debugln(args...)
}
func (l logger) Debugf(format string, args ...interface{}) {
	l.sourced().Debugf(format, args...)
}
func (l logger) Info(args ...interface{}) {
	l.sourced().Info(args...)
}
func (l logger) Infoln(args ...interface{}) {
	l.sourced().Infoln(args...)
}
func (l logger) Infof(format string, args ...interface{}) {
	l.sourced().Infof(format, args...)
}
func (l logger) Warn(args ...interface{}) {
	l.sourced().Warn(args...)
}
func (l logger) Warnln(args ...interface{}) {
	l.sourced().Warnln(args...)
}
func (l logger) Warnf(format string, args ...interface{}) {
	l.sourced().Warnf(format, args...)
}
func (l logger) Error(args ...interface{}) {
	l.sourced().Error(args...)
}
func (l logger) Errorln(args ...interface{}) {
	l.sourced().Errorln(args...)
}
func (l logger) Errorf(format string, args ...interface{}) {
	l.sourced().Errorf(format, args...)
}
func (l logger) Fatal(args ...interface{}) {
	l.sourced().Fatal(args...)
}
func (l logger) Fatalln(args ...interface{}) {
	l.sourced().Fatalln(args...)
}
func (l logger) Fatalf(format string, args ...interface{}) {
	l.sourced().Fatalf(format, args...)
}
func (l logger) SetLevel(level string) error {
	lvl, err := logrus.ParseLevel(level)
	if err != nil {
		return err
	}
	l.entry.Logger.Level = lvl
	return nil
}
func (l logger) SetFormat(format string) error {
	u, err := url.Parse(format)
	if err != nil {
		return err
	}
	if u.Scheme != "logger" {
		return fmt.Errorf("invalid scheme %s", u.Scheme)
	}
	jsonq := u.Query().Get("json")
	if jsonq == "true" {
		setJSONFormatter()
	}
	switch u.Opaque {
	case "syslog":
		if setSyslogFormatter == nil {
			return fmt.Errorf("system does not support syslog")
		}
		appname := u.Query().Get("appname")
		facility := u.Query().Get("local")
		return setSyslogFormatter(l, appname, facility)
	case "eventlog":
		if setEventlogFormatter == nil {
			return fmt.Errorf("system does not support eventlog")
		}
		name := u.Query().Get("name")
		debugAsInfo := false
		debugAsInfoRaw := u.Query().Get("debugAsInfo")
		if parsedDebugAsInfo, err := strconv.ParseBool(debugAsInfoRaw); err == nil {
			debugAsInfo = parsedDebugAsInfo
		}
		return setEventlogFormatter(l, name, debugAsInfo)
	case "stdout":
		l.entry.Logger.Out = os.Stdout
	case "stderr":
		l.entry.Logger.Out = os.Stderr
	default:
		return fmt.Errorf("unsupported logger %q", u.Opaque)
	}
	return nil
}
func (l logger) sourced() *logrus.Entry {
	_, file, line, ok := runtime.Caller(2)
	if !ok {
		file = "<???>"
		line = 1
	} else {
		slash := strings.LastIndex(file, "/")
		file = file[slash+1:]
	}
	return l.entry.WithField("source", fmt.Sprintf("%s:%d", file, line))
}
var origLogger = logrus.New()
var baseLogger = logger{entry: logrus.NewEntry(origLogger)}
func Base() Logger {
	return baseLogger
}
func NewLogger(w io.Writer) Logger {
	l := logrus.New()
	l.Out = w
	return logger{entry: logrus.NewEntry(l)}
}
func NewNopLogger() Logger {
	l := logrus.New()
	l.Out = ioutil.Discard
	return logger{entry: logrus.NewEntry(l)}
}
func With(key string, value interface{}) Logger {
	return baseLogger.With(key, value)
}
func Debug(args ...interface{}) {
	baseLogger.sourced().Debug(args...)
}
func Debugln(args ...interface{}) {
	baseLogger.sourced().Debugln(args...)
}
func Debugf(format string, args ...interface{}) {
	baseLogger.sourced().Debugf(format, args...)
}
func Info(args ...interface{}) {
	baseLogger.sourced().Info(args...)
}
func Infoln(args ...interface{}) {
	baseLogger.sourced().Infoln(args...)
}
func Infof(format string, args ...interface{}) {
	baseLogger.sourced().Infof(format, args...)
}
func Warn(args ...interface{}) {
	baseLogger.sourced().Warn(args...)
}
func Warnln(args ...interface{}) {
	baseLogger.sourced().Warnln(args...)
}
func Warnf(format string, args ...interface{}) {
	baseLogger.sourced().Warnf(format, args...)
}