mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Windows:Add ETW logging hook
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
afa3aec024
commit
92bf0a5046
3 changed files with 27 additions and 8 deletions
|
@ -3,7 +3,6 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/docker/docker/cli"
|
||||
"github.com/docker/docker/daemon/config"
|
||||
|
@ -70,13 +69,7 @@ func main() {
|
|||
// Set terminal emulation based on platform as required.
|
||||
_, stdout, stderr := term.StdStreams()
|
||||
|
||||
// @jhowardmsft - maybe there is a historic reason why on non-Windows, stderr is used
|
||||
// here. However, on Windows it makes no sense and there is no need.
|
||||
if runtime.GOOS == "windows" {
|
||||
logrus.SetOutput(stdout)
|
||||
} else {
|
||||
logrus.SetOutput(stderr)
|
||||
}
|
||||
initLogging(stdout, stderr)
|
||||
|
||||
onError := func(err error) {
|
||||
fmt.Fprintf(stderr, "%s\n", err)
|
||||
|
|
|
@ -2,7 +2,17 @@
|
|||
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func runDaemon(opts *daemonOptions) error {
|
||||
daemonCli := NewDaemonCli()
|
||||
return daemonCli.start(opts)
|
||||
}
|
||||
|
||||
func initLogging(_, stderr io.Writer) {
|
||||
logrus.SetOutput(stderr)
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/Microsoft/go-winio/pkg/etwlogrus"
|
||||
_ "github.com/docker/docker/autogen/winresources/dockerd"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
@ -36,3 +38,17 @@ func runDaemon(opts *daemonOptions) error {
|
|||
notifyShutdown(err)
|
||||
return err
|
||||
}
|
||||
|
||||
func initLogging(stdout, _ io.Writer) {
|
||||
// Maybe there is a historic reason why on non-Windows, stderr is used
|
||||
// for output. However, on Windows it makes no sense and there is no need.
|
||||
logrus.SetOutput(stdout)
|
||||
|
||||
// Provider ID: {6996f090-c5de-5082-a81e-5841acc3a635}
|
||||
// Hook isn't closed explicitly, as it will exist until process exit.
|
||||
// GUID is generated based on name - see Microsoft/go-winio/tools/etw-provider-gen.
|
||||
if hook, err := etwlogrus.NewHook("Moby"); err == nil {
|
||||
logrus.AddHook(hook)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue