Example #1
0
File: main.go Project: xaevman/prun
// printUsage prints help text for the application.
func printUsage() {
	fmt.Println("Usage:")
	fmt.Printf("\t%s <worker count> <command>\n", app.GetName())
	fmt.Println()
	fmt.Println("\tWhere <command> is the command to run for each input argument.")
	fmt.Printf("\tThe string '{}' within the command will be replaced with the argument")
	fmt.Println("comming in from the input pipeline.")
	fmt.Println()
	fmt.Printf("\texample: find . -type f | %s ls -alh {}\n", app.GetName())
}
Example #2
0
// NewCrashReport generates a new CrashReport object, fills it in
// with information about the current system state, and returns a reference
// to the new object back to the caller.
func NewCrashReport(errData interface{}) *CrashReport {
	var ms runtime.MemStats
	runtime.ReadMemStats(&ms)

	hostname, _ := os.Hostname()
	wd, _ := os.Getwd()

	rpt := &CrashReport{
		Timestamp:   time.Now(),
		ErrData:     errData,
		AppName:     app.GetName(),
		AppPath:     app.GetExeDir(),
		GoOS:        runtime.GOOS,
		GoArch:      runtime.GOARCH,
		CPUCount:    runtime.NumCPU(),
		HostName:    hostname,
		WorkingDir:  wd,
		Environment: os.Environ(),
		StackTrace:  NewStackTrace(),
	}

	if verboseRpt {
		rpt.MemStats = &ms
	} else {
		rpt.MemStats = &TerseMemStats{
			Alloc:       ms.Alloc,
			Mallocs:     ms.Mallocs,
			Frees:       ms.Frees,
			HeapIdle:    ms.HeapIdle,
			HeapInuse:   ms.HeapInuse,
			HeapObjects: ms.HeapObjects,
			StackInuse:  ms.StackInuse,
			NumGC:       ms.NumGC,
			//            GCCPUFraction : ms.GCCPUFraction,
			EnableGC: ms.EnableGC,
			DebugGC:  ms.DebugGC,
		}
	}

	return rpt
}