mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
add option to log debug messages to unix or tcp socket
This commit is contained in:
parent
f3d26e038d
commit
bc08b85191
@ -78,4 +78,5 @@ func (log *CTopLogger) Exit() {
|
||||
StopServer()
|
||||
}
|
||||
|
||||
func debugMode() bool { return os.Getenv("CTOP_DEBUG") == "1" }
|
||||
func debugMode() bool { return os.Getenv("CTOP_DEBUG") == "1" }
|
||||
func debugModeTCP() bool { return os.Getenv("CTOP_DEBUG_TCP") == "1" }
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user