Пример #1
0
// Fail prints an error message at blog.ERROR level and then quits with exit status ErrorExitStatus.
func Fail(arg0 interface{}, args ...interface{}) {
	if len(args) == 0 {
		blog.Error(arg0)
	} else {
		switch arg0.(type) {
		case string:
			blog.Error(arg0.(string), args...)
		default:
			blog.Error(arg0, args...)
		}
	}
	blog.Close()
	os.Exit(ErrorExitStatus)
}
Пример #2
0
func TestWarn(t *testing.T) {
	config.BanyanUpdate = bup
	a := 2
	b := "hello %d"
	fmt.Println("Expected output: 2 hello %d")
	Warn(a, b)
	fmt.Println()
	fmt.Println("Expected output: hello 2")
	Warn(b, a)
	fmt.Println()
	fmt.Println("Expected output: hello %d")
	Warn(b)
	fmt.Println()

	e := errors.New("An error message")
	imageList := "imageList"
	fmt.Println("Expected output: An error message: Error in opening imageList: perhaps a fresh start?")
	Warn(e, ": Error in opening", imageList, ": perhaps a fresh start?")
	fmt.Println()
	blog.Close()
}