Esempio n. 1
0
func main() {
	// Start with default level: Trace,
	// or use `beewatch.Start(beewatch.Info())` to set the level.
	beewatch.Start()

	// Some variables.
	appName := "Bee Watch"
	boolean := true
	number := 3862
	floatNum := 3.1415926
	test := "fail to watch"

	// Add variables to be watched, must be even sized.
	// Note that you have to pass the pointer.
	// For now, it only supports basic types.
	// In this case, 'test' will not be watched.
	beewatch.AddWatchVars("test", test, "App Name", &appName,
		"bool", &boolean, "number", &number, "float", &floatNum)

	// Display something, must be even sized.
	beewatch.Info().Display("App Name", appName).Break().
		Printf("boolean value is %v; number is %d", boolean, number)

	beewatch.Critical().Break().Display("float", floatNum)

	// Change some values.
	appName = "Bee Watch2"
	number = 250
	// Here you will see something interesting.
	beewatch.Trace().Break()

	// Multiple goroutines test.
	for i := 0; i < 3; i++ {
		go multipletest(i)
	}

	beewatch.Trace().Printf("Wait 3 seconds...")
	select {
	case <-time.After(3 * time.Second):
		beewatch.Trace().Printf("Done debug")
	}

	// Close debugger,
	// it's not useful when you debug a web server that may not have an end.
	beewatch.Close()
}
Esempio n. 2
0
func init() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	// Set App version and log level.
	if beego.AppConfig.String("runmode") == "pro" {
		beego.SetLevel(beego.LevelInfo)

		beego.Info("Beego Web", APP_VER)

		os.Mkdir("./log", os.ModePerm)
		filew := beego.NewFileWriter("log/log", true)
		err := filew.StartLogger()
		if err != nil {
			beego.Critical("NewFileWriter ->", err)
		}
	} else {
		beewatch.Start(beewatch.Trace)
	}
}