aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2019-04-27 15:02:52 +0300
committerTulir Asokan <tulir@maunium.net>2019-04-27 15:02:52 +0300
commit6f54066c43172fe0197e82fb1034c9ae55d1e1f2 (patch)
tree8136e34231de96d9557f2fc0f12e499ca6c2978f /main.go
parentbc7e2d9a1c871e3fbce932f9695fc24083bc2cc4 (diff)
Add partial deadlock detection in debug mode
Diffstat (limited to 'main.go')
-rw-r--r--main.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/main.go b/main.go
index e925f3e..43f4d2b 100644
--- a/main.go
+++ b/main.go
@@ -22,6 +22,7 @@ import (
"os"
"path/filepath"
"runtime"
+ "strings"
"time"
"maunium.net/go/gomuks/debug"
@@ -32,11 +33,21 @@ import (
var MainUIProvider ifc.UIProvider = ui.NewGomuksUI
func main() {
+ debugDir := os.Getenv("DEBUG_DIR")
+ if len(debugDir) > 0 {
+ debug.LogDirectory = debugDir
+ }
+ debugLevel := strings.ToLower(os.Getenv("DEBUG"))
+ if debugLevel != "0" && debugLevel != "f" && debugLevel != "false" {
+ debug.WriteLogs = true
+ }
+ if debugLevel == "1" || debugLevel == "t" || debugLevel == "true" {
+ debug.RecoverPrettyPanic = false
+ debug.DeadlockDetection = true
+ }
+ debug.Initialize()
defer debug.Recover()
- enableDebug := len(os.Getenv("DEBUG")) > 0
- debug.RecoverPrettyPanic = !enableDebug
-
configDir, err := UserConfigDir()
if err != nil {
fmt.Fprintln(os.Stderr, "Failed to get config directory:", err)