Ensure log writes only to os.Stderr for env and config command

Signed-off-by: Nathan LeClaire <nathan.leclaire@gmail.com>
This commit is contained in:
Nathan LeClaire 2015-10-19 17:30:18 -07:00
parent 43543d1579
commit 17f0a32b79
2 changed files with 10 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package commands
import ( import (
"fmt" "fmt"
"net/url" "net/url"
"os"
"strings" "strings"
"github.com/docker/machine/cli" "github.com/docker/machine/cli"
@ -14,6 +15,10 @@ import (
) )
func cmdConfig(c *cli.Context) { func cmdConfig(c *cli.Context) {
// Ensure that log messages always go to stderr when this command is
// being run (it is intended to be run in a subshell)
log.SetOutWriter(os.Stderr)
if len(c.Args()) != 1 { if len(c.Args()) != 1 {
fatal(ErrExpectedOneMachine) fatal(ErrExpectedOneMachine)
} }

View File

@ -8,6 +8,7 @@ import (
"text/template" "text/template"
"github.com/docker/machine/cli" "github.com/docker/machine/cli"
"github.com/docker/machine/libmachine/log"
) )
const ( const (
@ -32,6 +33,10 @@ type ShellConfig struct {
} }
func cmdEnv(c *cli.Context) { func cmdEnv(c *cli.Context) {
// Ensure that log messages always go to stderr when this command is
// being run (it is intended to be run in a subshell)
log.SetOutWriter(os.Stderr)
if len(c.Args()) != 1 && !c.Bool("unset") { if len(c.Args()) != 1 && !c.Bool("unset") {
fatal(improperEnvArgsError) fatal(improperEnvArgsError)
} }