add option to log debug messages to unix or tcp socket

This commit is contained in:
Bradley Cicenas
2017-05-31 14:45:48 +00:00
parent f3d26e038d
commit bc08b85191
2 changed files with 11 additions and 3 deletions

View File

@@ -7,7 +7,8 @@ import (
)
const (
path = "./ctop.sock"
socketPath = "./ctop.sock"
socketAddr = "0.0.0.0:9000"
)
var server struct {
@@ -16,7 +17,13 @@ var server struct {
}
func getListener() net.Listener {
ln, err := net.Listen("unix", path)
var ln net.Listener
var err error
if debugModeTCP() {
ln, err = net.Listen("tcp", socketAddr)
} else {
ln, err = net.Listen("unix", socketPath)
}
if err != nil {
panic(err)
}