// Trace is a function for non-helper functions to call on call.  It will
// always log to file and optionally with -debug print to stdout and
// also will have nice coloredoutput as long as -nocolor is not supplied.
// Don't:
//   Use on primitive, short or otherwise uneeded functions.  An example
//   of ones would be the logging functions
// Do:
//   Use on complicated functions, an example would be most of the sde.go
//   file and any method that uses util.TimeFunction on a defer.
func Trace(i ...interface{}) {
	s := TypeString(i)
	if DebugLog {
		if Color {
			term.Green(os.Stdout, "Trace: "+s+"\n")
		} else {
			fmt.Print("Trace: " + s)
		}
	}
	Log.SetPrefix("TRACE ")
	Log.Println(s)
	log.SetPrefix("")
}
Exemple #2
0
func main() {
	// On windows, it is possible, though unlikely,
	// to fail to write to the console. An error
	// is returned.
	f := os.Stdout

	if err := term.Black(f, "Black"); err != nil {
		fmt.Printf("Stupid windows system calls: %v\n", err)
	}

	fmt.Println()
	term.White(f, "White")
	fmt.Println()
	term.Red(f, "Red")
	fmt.Println()
	term.LightRed(f, "Light Red")
	fmt.Println()
	term.Green(f, "Green")
	fmt.Println()
	term.LightGreen(f, "Light Green")
	fmt.Println()
	term.DarkYellow(f, "Dark Yellow")
	fmt.Println()
	term.LightYellow(f, "Light Yellow")
	fmt.Println()
	term.Blue(f, "Blue")
	fmt.Println()
	term.LightBlue(f, "Light Blue")
	fmt.Println()
	term.Magenta(f, "Magenta")
	fmt.Println()
	term.LightMagenta(f, "Light Magenta")
	fmt.Println()
	term.Cyan(f, "Cyan")
	fmt.Println()
	term.LightCyan(f, "Light Cyan")
	fmt.Println()
}