1
1
mirror of https://github.com/walles/moar.git synced 2024-11-30 12:42:26 +03:00

Print bug reporting info on log messages

diff --git moar.go moar.go
index 46b2898..906b310 100644
--- moar.go
+++ moar.go
@@ -58,6 +58,23 @@ func _PrintUsage(output io.Writer) {
 	}
 }

+// PrintProblemsHeader prints bug reporting information to stderr
+func PrintProblemsHeader() {
+	fmt.Fprintln(os.Stderr, "Please post the following report at <https://github.com/walles/moar/issues>,")
+	fmt.Fprintln(os.Stderr, "or e-mail it to johan.walles@gmail.com.")
+	fmt.Fprintln(os.Stderr)
+	fmt.Fprintln(os.Stderr, "Version:", versionString)
+	fmt.Fprintln(os.Stderr, "LANG   :", os.Getenv("LANG"))
+	fmt.Fprintln(os.Stderr, "TERM   :", os.Getenv("TERM"))
+	fmt.Fprintln(os.Stderr)
+	fmt.Fprintln(os.Stderr, "GOOS    :", runtime.GOOS)
+	fmt.Fprintln(os.Stderr, "GOARCH  :", runtime.GOARCH)
+	fmt.Fprintln(os.Stderr, "Compiler:", runtime.Compiler)
+	fmt.Fprintln(os.Stderr, "NumCPU  :", runtime.NumCPU())
+
+	fmt.Fprintln(os.Stderr)
+}
+
 func main() {
 	// FIXME: If we get a CTRL-C, get terminal back into a useful state before terminating

@@ -67,21 +84,7 @@ func main() {
 			return
 		}

-		// On any panic or warnings, also print system info and how to report bugs
-		fmt.Fprintln(os.Stderr, "Please post the following crash report at <https://github.com/walles/moar/issues>,")
-		fmt.Fprintln(os.Stderr, "or e-mail it to johan.walles@gmail.com.")
-		fmt.Fprintln(os.Stderr)
-		fmt.Fprintln(os.Stderr, "Version:", versionString)
-		fmt.Fprintln(os.Stderr, "LANG   :", os.Getenv("LANG"))
-		fmt.Fprintln(os.Stderr, "TERM   :", os.Getenv("TERM"))
-		fmt.Fprintln(os.Stderr)
-		fmt.Fprintln(os.Stderr, "GOOS    :", runtime.GOOS)
-		fmt.Fprintln(os.Stderr, "GOARCH  :", runtime.GOARCH)
-		fmt.Fprintln(os.Stderr, "Compiler:", runtime.Compiler)
-		fmt.Fprintln(os.Stderr, "NumCPU  :", runtime.NumCPU())
-
-		fmt.Fprintln(os.Stderr)
-
+		PrintProblemsHeader()
 		panic(err)
 	}()

@@ -161,6 +164,8 @@ func _StartPaging(reader *m.Reader) {
 		}

 		if len(loglines.String()) > 0 {
+			PrintProblemsHeader()
+
 			// FIXME: Don't print duplicate log messages more than once,
 			// maybe invent our own logger for this?
 			fmt.Fprintf(os.Stderr, "%s", loglines.String())

Change-Id: If41c17e98daf9f05909ab7e3c31dc84e946cbbf5
This commit is contained in:
Johan Walles 2019-11-19 15:33:00 +01:00
parent 2df60227cf
commit d96bb923a1

35
moar.go
View File

@ -58,6 +58,23 @@ func _PrintUsage(output io.Writer) {
} }
} }
// PrintProblemsHeader prints bug reporting information to stderr
func PrintProblemsHeader() {
fmt.Fprintln(os.Stderr, "Please post the following report at <https://github.com/walles/moar/issues>,")
fmt.Fprintln(os.Stderr, "or e-mail it to johan.walles@gmail.com.")
fmt.Fprintln(os.Stderr)
fmt.Fprintln(os.Stderr, "Version:", versionString)
fmt.Fprintln(os.Stderr, "LANG :", os.Getenv("LANG"))
fmt.Fprintln(os.Stderr, "TERM :", os.Getenv("TERM"))
fmt.Fprintln(os.Stderr)
fmt.Fprintln(os.Stderr, "GOOS :", runtime.GOOS)
fmt.Fprintln(os.Stderr, "GOARCH :", runtime.GOARCH)
fmt.Fprintln(os.Stderr, "Compiler:", runtime.Compiler)
fmt.Fprintln(os.Stderr, "NumCPU :", runtime.NumCPU())
fmt.Fprintln(os.Stderr)
}
func main() { func main() {
// FIXME: If we get a CTRL-C, get terminal back into a useful state before terminating // FIXME: If we get a CTRL-C, get terminal back into a useful state before terminating
@ -67,21 +84,7 @@ func main() {
return return
} }
// On any panic or warnings, also print system info and how to report bugs PrintProblemsHeader()
fmt.Fprintln(os.Stderr, "Please post the following crash report at <https://github.com/walles/moar/issues>,")
fmt.Fprintln(os.Stderr, "or e-mail it to johan.walles@gmail.com.")
fmt.Fprintln(os.Stderr)
fmt.Fprintln(os.Stderr, "Version:", versionString)
fmt.Fprintln(os.Stderr, "LANG :", os.Getenv("LANG"))
fmt.Fprintln(os.Stderr, "TERM :", os.Getenv("TERM"))
fmt.Fprintln(os.Stderr)
fmt.Fprintln(os.Stderr, "GOOS :", runtime.GOOS)
fmt.Fprintln(os.Stderr, "GOARCH :", runtime.GOARCH)
fmt.Fprintln(os.Stderr, "Compiler:", runtime.Compiler)
fmt.Fprintln(os.Stderr, "NumCPU :", runtime.NumCPU())
fmt.Fprintln(os.Stderr)
panic(err) panic(err)
}() }()
@ -161,6 +164,8 @@ func _StartPaging(reader *m.Reader) {
} }
if len(loglines.String()) > 0 { if len(loglines.String()) > 0 {
PrintProblemsHeader()
// FIXME: Don't print duplicate log messages more than once, // FIXME: Don't print duplicate log messages more than once,
// maybe invent our own logger for this? // maybe invent our own logger for this?
fmt.Fprintf(os.Stderr, "%s", loglines.String()) fmt.Fprintf(os.Stderr, "%s", loglines.String())