Optional logging even in background
This commit is contained in:
parent
e75d2d4496
commit
c1e097d6d0
|
@ -13,7 +13,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LogLevelError = iota
|
LogLevelSilent = iota
|
||||||
|
LogLevelError
|
||||||
LogLevelInfo
|
LogLevelInfo
|
||||||
LogLevelDebug
|
LogLevelDebug
|
||||||
)
|
)
|
||||||
|
@ -35,7 +36,10 @@ func NewLogger(level int, prepend string) *Logger {
|
||||||
if level >= LogLevelInfo {
|
if level >= LogLevelInfo {
|
||||||
return output, output, ioutil.Discard
|
return output, output, ioutil.Discard
|
||||||
}
|
}
|
||||||
return output, ioutil.Discard, ioutil.Discard
|
if level >= LogLevelError {
|
||||||
|
return output, ioutil.Discard, ioutil.Discard
|
||||||
|
}
|
||||||
|
return ioutil.Discard, ioutil.Discard, ioutil.Discard
|
||||||
}()
|
}()
|
||||||
|
|
||||||
logger.Debug = log.New(logDebug,
|
logger.Debug = log.New(logDebug,
|
||||||
|
|
13
main.go
13
main.go
|
@ -111,6 +111,8 @@ func main() {
|
||||||
return LogLevelInfo
|
return LogLevelInfo
|
||||||
case "error":
|
case "error":
|
||||||
return LogLevelError
|
return LogLevelError
|
||||||
|
case "silent":
|
||||||
|
return LogLevelSilent
|
||||||
}
|
}
|
||||||
return LogLevelInfo
|
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=3", ENV_WG_TUN_FD))
|
||||||
env = append(env, fmt.Sprintf("%s=4", ENV_WG_UAPI_FD))
|
env = append(env, fmt.Sprintf("%s=4", ENV_WG_UAPI_FD))
|
||||||
env = append(env, fmt.Sprintf("%s=1", ENV_WG_PROCESS_FOREGROUND))
|
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{
|
attr := &os.ProcAttr{
|
||||||
Files: []*os.File{
|
Files: []*os.File{
|
||||||
nil, // stdin
|
files[0], // stdin
|
||||||
nil, // stdout
|
files[1], // stdout
|
||||||
nil, // stderr
|
files[2], // stderr
|
||||||
tun.File(),
|
tun.File(),
|
||||||
fileUAPI,
|
fileUAPI,
|
||||||
},
|
},
|
||||||
|
|
1
uapi.go
1
uapi.go
|
@ -235,7 +235,6 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError {
|
||||||
dummy = device.staticIdentity.publicKey.Equals(publicKey)
|
dummy = device.staticIdentity.publicKey.Equals(publicKey)
|
||||||
device.staticIdentity.mutex.RUnlock()
|
device.staticIdentity.mutex.RUnlock()
|
||||||
|
|
||||||
|
|
||||||
if dummy {
|
if dummy {
|
||||||
peer = &Peer{}
|
peer = &Peer{}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue