forked from libopenstorage/openstorage
/
log.go
36 lines (29 loc) · 751 Bytes
/
log.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package dbg
import (
"os"
"github.com/sirupsen/logrus"
)
func LogErrorAndPanicf(err error, format string, args ...interface{}) {
logrus.Errorf("LogErrorAndPanicf: error: %v", err)
panicf(format, args...)
}
// Panicf outputs error message, dumps threads and exits.
func Panicf(format string, args ...interface{}) {
panicf(format, args...)
}
// Panicf outputs error message, dumps threads and exits.
func panicf(format string, args ...interface{}) {
logrus.Warnf(format, args...)
err := DumpGoProfile()
if err != nil {
logrus.Fatal(err)
}
DumpHeap()
os.Exit(6)
}
// Assert Panicf's if the condition evaluates to false.
func Assert(condition bool, format string, args ...interface{}) {
if !condition {
Panicf(format, args...)
}
}