Signed-off-by: John Howard <jhoward@microsoft.com>
| ... | ... |
@@ -104,7 +104,14 @@ func main() {
|
| 104 | 104 |
|
| 105 | 105 |
// Set terminal emulation based on platform as required. |
| 106 | 106 |
_, stdout, stderr := term.StdStreams() |
| 107 |
- logrus.SetOutput(stderr) |
|
| 107 |
+ |
|
| 108 |
+ // @jhowardmsft - maybe there is a historic reason why on non-Windows, stderr is used |
|
| 109 |
+ // here. However, on Windows it makes no sense and there is no need. |
|
| 110 |
+ if runtime.GOOS == "windows" {
|
|
| 111 |
+ logrus.SetOutput(stdout) |
|
| 112 |
+ } else {
|
|
| 113 |
+ logrus.SetOutput(stderr) |
|
| 114 |
+ } |
|
| 108 | 115 |
|
| 109 | 116 |
cmd := newDaemonCommand() |
| 110 | 117 |
cmd.SetOutput(stdout) |
| ... | ... |
@@ -5,6 +5,7 @@ import ( |
| 5 | 5 |
"errors" |
| 6 | 6 |
"fmt" |
| 7 | 7 |
"io/ioutil" |
| 8 |
+ "log" |
|
| 8 | 9 |
"os" |
| 9 | 10 |
"os/exec" |
| 10 | 11 |
"path/filepath" |
| ... | ... |
@@ -409,6 +410,12 @@ func initPanicFile(path string) error {
|
| 409 | 409 |
return err |
| 410 | 410 |
} |
| 411 | 411 |
|
| 412 |
+ // Reset os.Stderr to the panic file (so fmt.Fprintf(os.Stderr,...) actually gets redirected) |
|
| 413 |
+ os.Stderr = os.NewFile(uintptr(panicFile.Fd()), "/dev/stderr") |
|
| 414 |
+ |
|
| 415 |
+ // Force threads that panic to write to stderr (the panicFile handle now), otherwise it will go into the ether |
|
| 416 |
+ log.SetOutput(os.Stderr) |
|
| 417 |
+ |
|
| 412 | 418 |
return nil |
| 413 | 419 |
} |
| 414 | 420 |
|