OxyLogger

This commit is contained in:
emile 2015-09-17 16:29:44 +02:00
parent 7b96decf17
commit 56b8f47a85

View file

@ -26,6 +26,7 @@ var (
currentConfiguration = new(Configuration) currentConfiguration = new(Configuration)
metrics = stats.New() metrics = stats.New()
log = logging.MustGetLogger("traefik") log = logging.MustGetLogger("traefik")
oxyLogger = &OxyLogger{}
templatesRenderer = render.New(render.Options{ templatesRenderer = render.New(render.Options{
Directory: "templates", Directory: "templates",
Asset: Asset, Asset: Asset,
@ -33,6 +34,21 @@ var (
}) })
) )
type OxyLogger struct{
}
func (oxylogger *OxyLogger) Infof(format string, args ...interface{}) {
log.Info(format, args...)
}
func (oxylogger *OxyLogger) Warningf(format string, args ...interface{}) {
log.Warning(format, args...)
}
func (oxylogger *OxyLogger) Errorf(format string, args ...interface{}) {
log.Error(format, args...)
}
func main() { func main() {
kingpin.Parse() kingpin.Parse()
var srv *graceful.Server var srv *graceful.Server
@ -187,7 +203,7 @@ func LoadConfig(configuration *Configuration, gloablConfiguration *GlobalConfigu
for frontendName, frontend := range configuration.Frontends { for frontendName, frontend := range configuration.Frontends {
log.Debug("Creating frontend %s", frontendName) log.Debug("Creating frontend %s", frontendName)
fwd, _ := forward.New() fwd, _ := forward.New()
newRoute := router.NewRoute() newRoute := router.NewRoute().Name(frontendName)
for routeName, route := range frontend.Routes { for routeName, route := range frontend.Routes {
log.Debug("Creating route %s", routeName) log.Debug("Creating route %s", routeName)
newRouteReflect := Invoke(newRoute, route.Rule, route.Value) newRouteReflect := Invoke(newRoute, route.Rule, route.Value)
@ -196,7 +212,7 @@ func LoadConfig(configuration *Configuration, gloablConfiguration *GlobalConfigu
if backends[frontend.Backend] == nil { if backends[frontend.Backend] == nil {
log.Debug("Creating backend %s", frontend.Backend) log.Debug("Creating backend %s", frontend.Backend)
lb, _ := roundrobin.New(fwd) lb, _ := roundrobin.New(fwd)
rb, _ := roundrobin.NewRebalancer(lb) rb, _ := roundrobin.NewRebalancer(lb, roundrobin.RebalancerLogger(oxyLogger))
for serverName, server := range configuration.Backends[frontend.Backend].Servers { for serverName, server := range configuration.Backends[frontend.Backend].Servers {
log.Debug("Creating server %s", serverName) log.Debug("Creating server %s", serverName)
url, _ := url.Parse(server.Url) url, _ := url.Parse(server.Url)
@ -206,6 +222,7 @@ func LoadConfig(configuration *Configuration, gloablConfiguration *GlobalConfigu
} else { } else {
log.Debug("Reusing backend %s", frontend.Backend) log.Debug("Reusing backend %s", frontend.Backend)
} }
// stream.New(backends[frontend.Backend], stream.Retry("IsNetworkError() && Attempts() <= " + strconv.Itoa(gloablConfiguration.Replay)), stream.Logger(oxyLogger))
newRoute.Handler(backends[frontend.Backend]) newRoute.Handler(backends[frontend.Backend])
err := newRoute.GetError() err := newRoute.GetError()
if err != nil { if err != nil {