Skip to content

Instantly share code, notes, and snippets.

@agtorre
Last active January 1, 2016 20:49
Show Gist options
  • Save agtorre/8199241 to your computer and use it in GitHub Desktop.
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
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"))
}
@agtorre
Copy link
Author

agtorre commented Dec 31, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment