open-nomad/command/docker_logger_plugin.go
Alex Dadgar 14ed757a56 Plugins use parent loggers
This PR fixes various instances of plugins being launched without using
the parent loggers. This meant that logs would not all go to the same
output, break formatting etc.
2019-01-11 11:36:37 -08:00

44 lines
1,013 B
Go

package command
import (
"strings"
log "github.com/hashicorp/go-hclog"
plugin "github.com/hashicorp/go-plugin"
"github.com/hashicorp/nomad/drivers/docker/docklog"
"github.com/hashicorp/nomad/plugins/base"
)
type DockerLoggerPluginCommand struct {
Meta
}
func (e *DockerLoggerPluginCommand) Help() string {
helpText := `
This is a command used by Nomad internally to launch the docker logger process"
`
return strings.TrimSpace(helpText)
}
func (e *DockerLoggerPluginCommand) Synopsis() string {
return "internal - launch a docker logger plugin"
}
func (e *DockerLoggerPluginCommand) Run(args []string) int {
logger := log.New(&log.LoggerOptions{
Level: log.Trace,
JSONFormat: true,
Name: docklog.PluginName,
})
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: base.Handshake,
Plugins: map[string]plugin.Plugin{
docklog.PluginName: docklog.NewPlugin(docklog.NewDockerLogger(logger)),
},
GRPCServer: plugin.DefaultGRPCServer,
Logger: logger,
})
return 0
}