Exemplo n.º 1
0
func Start() {
	fn := os2.Executable()

	f, err := os.Create(fn + ".cpu.prof")
	RaiseIf(err)

	pprof.StartCPUProfile(f)
	// runtime.SetCPUProfileRate(1000000)
}
Exemplo n.º 2
0
func readuser() []String {
	usertxt := String(filepath.Join(filepath.Dir(os2.Executable()), "user.txt"))
	acc, err := io2.ReadTextToLines(usertxt)
	RaiseIf(err)

	if len(acc) < 2 {
		Raise("corrupt user.txt")
	}

	return acc
}
Exemplo n.º 3
0
func (self *Logger) getDefaultFileName() string {
	now := time.Now()
	year, month, day := now.Date()
	hour, minute, second := now.Clock()
	exe := os2.Executable()
	exeName := filepath.Base(exe)

	baseName := fmt.Sprintf("[%s][%s][%04d-%02d-%02d %02d.%02d.%02d][%d].txt", exeName[:len(filepath.Ext(exeName))], self.tag, year, month, day, hour, minute, second, os.Getpid())

	logPath := filepath.Join(filepath.Dir(exe), "logs")
	err := os.MkdirAll(logPath, 0666)
	if err != nil {
		return ""
	}

	return filepath.Join(logPath, baseName)
}
Exemplo n.º 4
0
func Stop() {
	pprof.StopCPUProfile()
	f, err := os.Create(os2.Executable() + ".mem.prof")
	RaiseIf(err)
	pprof.WriteHeapProfile(f)
}