OSDN Git Service

Merge pull request #41 from Bytom/dev
[bytom/vapor.git] / common / debug.go
1 package common
2
3 import (
4         "fmt"
5         "os"
6         "runtime"
7         "runtime/debug"
8         "strings"
9 )
10
11 // Report gives off a warning requesting the user to submit an issue to the github tracker.
12 func Report(extra ...interface{}) {
13         fmt.Fprintln(os.Stderr, "You've encountered a sought after, hard to reproduce bug. Please report this to the developers <3 https://github.com/ethereum/go-ethereum/issues")
14         fmt.Fprintln(os.Stderr, extra...)
15
16         _, file, line, _ := runtime.Caller(1)
17         fmt.Fprintf(os.Stderr, "%v:%v\n", file, line)
18
19         debug.PrintStack()
20
21         fmt.Fprintln(os.Stderr, "#### BUG! PLEASE REPORT ####")
22 }
23
24 // PrintDepricationWarning prinst the given string in a box using fmt.Println.
25 func PrintDepricationWarning(str string) {
26         line := strings.Repeat("#", len(str)+4)
27         emptyLine := strings.Repeat(" ", len(str))
28         fmt.Printf(`
29 %s
30 # %s #
31 # %s #
32 # %s #
33 %s
34
35 `, line, emptyLine, str, emptyLine, line)
36 }