mirror of https://github.com/docker/docs.git
Move call logger to a separate backend (more backends to come)
This commit is contained in:
parent
ca7c1fbf49
commit
cd9abab36a
|
@ -0,0 +1,30 @@
|
||||||
|
package backends
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/dotcloud/docker/engine"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Debug() engine.Installer {
|
||||||
|
return &debug{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type debug struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *debug) Install(eng *engine.Engine) error {
|
||||||
|
eng.RegisterCatchall(func(job *engine.Job) engine.Status {
|
||||||
|
fmt.Printf("--> %s %s\n", job.Name, strings.Join(job.Args, " "))
|
||||||
|
for k, v := range job.Env().Map() {
|
||||||
|
fmt.Printf(" %s=%s\n", k, v)
|
||||||
|
}
|
||||||
|
// This helps us detect the race condition if our time.Sleep
|
||||||
|
// missed it. (see comment in main)
|
||||||
|
if job.Name == "acceptconnections" {
|
||||||
|
panic("race condition in github.com/dotcloud/docker/api/server/ServeApi")
|
||||||
|
}
|
||||||
|
return engine.StatusOK
|
||||||
|
})
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -1,29 +1,20 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/docker/swarmd/backends"
|
||||||
"github.com/dotcloud/docker/api/server"
|
"github.com/dotcloud/docker/api/server"
|
||||||
"github.com/dotcloud/docker/engine"
|
"github.com/dotcloud/docker/engine"
|
||||||
"strings"
|
|
||||||
"os"
|
"os"
|
||||||
"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
eng := engine.New()
|
eng := engine.New()
|
||||||
eng.Logging = false
|
eng.Logging = false
|
||||||
eng.RegisterCatchall(func(job *engine.Job) engine.Status {
|
if err := backends.Debug().Install(eng); err != nil {
|
||||||
fmt.Printf("--> %s %s\n", job.Name, strings.Join(job.Args, " "))
|
Fatalf("%v", err)
|
||||||
for k, v := range job.Env().Map() {
|
|
||||||
fmt.Printf(" %s=%s\n", k, v)
|
|
||||||
}
|
}
|
||||||
// This helps us detect the race condition if our time.Sleep
|
|
||||||
// missed it. (see comment below)
|
|
||||||
if job.Name == "acceptconnections" {
|
|
||||||
panic("race condition in github.com/dotcloud/docker/api/server/ServeApi")
|
|
||||||
}
|
|
||||||
return engine.StatusOK
|
|
||||||
})
|
|
||||||
eng.Register(os.Args[0], server.ServeApi)
|
eng.Register(os.Args[0], server.ServeApi)
|
||||||
|
|
||||||
// Register the entrypoint job as the current proces command name,
|
// Register the entrypoint job as the current proces command name,
|
||||||
|
|
Loading…
Reference in New Issue