Last active
January 1, 2016 20:49
-
-
Save agtorre/8199241 to your computer and use it in GitHub Desktop.
The start of colorizing logs for revel using the new colorize package I'm developing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"colorize/colorize" | |
"fmt" | |
"log" | |
"os" | |
) | |
var ( | |
REVEL_INFO *log.Logger | |
) | |
func main(){ | |
//Revel Example | |
//first set some color information | |
var info, green colorize.Colorize | |
info.SetColor(colorize.COLOR_YELLOW) | |
green.SetColor(colorize.COLOR_GREEN) | |
//helper functions to shorten code | |
g := green.Fmt | |
i := info.Fmt | |
//Define the look/feel of the INFO logger | |
REVEL_INFO = log.New(os.Stdout, i("INFO "), log.Ldate|log.Lmicroseconds|log.Lshortfile) | |
//print out some messages, note the i wrappers for yellow text on the actual info string | |
fmt.Println(g("~")) | |
fmt.Println(g("~ revel! http://robfig.github.com/revel")) | |
fmt.Println(g("~")) | |
REVEL_INFO.Println(i("Loaded module static")) | |
REVEL_INFO.Println(i("Loaded module testrunner")) | |
REVEL_INFO.Println(i("Running hello (hello) in dev mode")) | |
REVEL_INFO.Println(i("Listening on :9000")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Discussion: https://groups.google.com/forum/#!topic/revel-framework/4-UEwJ4FgP4
Screenshot: http://goo.gl/3MZjII