diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-14 03:38:06 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-14 03:38:06 +0200 |
commit | c1e097d6d0cabb81b3aa180d69107f9857606bf5 (patch) | |
tree | 000c3ba19fa2c3a6da7fe848cdaf9e9d313cede8 /main.go | |
parent | e75d2d4496643ef6b4033d574cd47b92aeb21a11 (diff) |
Optional logging even in background
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -111,6 +111,8 @@ func main() { return LogLevelInfo case "error": return LogLevelError + case "silent": + return LogLevelSilent } return LogLevelInfo }() @@ -183,11 +185,16 @@ func main() { env = append(env, fmt.Sprintf("%s=3", ENV_WG_TUN_FD)) env = append(env, fmt.Sprintf("%s=4", ENV_WG_UAPI_FD)) env = append(env, fmt.Sprintf("%s=1", ENV_WG_PROCESS_FOREGROUND)) + files := [3]*os.File{} + if os.Getenv("LOG_LEVEL") != "" { + files[1] = os.Stdout + files[2] = os.Stderr + } attr := &os.ProcAttr{ Files: []*os.File{ - nil, // stdin - nil, // stdout - nil, // stderr + files[0], // stdin + files[1], // stdout + files[2], // stderr tun.File(), fileUAPI, }, |