12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- package sizer
- import (
- "log"
- "github.com/fatih/color"
- )
- // Debug is a global bool to toggle debugging messages.
- var Debug bool
- type console log.Logger
- func (l *console) SetFlags(i int) {
- log.SetFlags(i)
- }
- func (l *console) Print(v ...interface{}) {
- log.Print(v...)
- }
- func (l *console) Printf(format string, v ...interface{}) {
- log.Printf(format, v...)
- }
- func (l *console) Println(v ...interface{}) {
- log.Println(v...)
- }
- func (l *console) Fatal(v ...interface{}) {
- log.Fatal(v...)
- }
- func (l *console) Fatalf(format string, v ...interface{}) {
- log.Fatalf(format, v...)
- }
- func (l *console) Fatalln(v ...interface{}) {
- log.Fatalln(v...)
- }
- func (l *console) Debug(msg ...interface{}) {
- if Debug {
- l.Print(msg...)
- }
- }
- func (l *console) Debugf(format string, msg ...interface{}) {
- if Debug {
- l.Printf(format, msg...)
- }
- }
- func (l *console) Debugln(msg ...interface{}) {
- if Debug {
- l.Println(msg...)
- }
- }
- // Console is the logger object
- var Console console
- func init() {
- Console.SetFlags(0)
- }
- // Red is a function that, given a string, returns the string
- // in ANSI red foreground color.
- var Red = color.New(color.FgRed).SprintFunc()
- // Green is a function that, given a string, returns the string
- // in ANSI green foreground color.
- var Green = color.New(color.FgGreen).SprintFunc()
- // Cyan is a function that, given a string, returns the string
- // in ANSI cyan foreground color.
- var Cyan = color.New(color.FgCyan).SprintFunc()
- // Yellow is a function that, given a string, returns the string
- // in ANSI yellow foreground color.
- var Yellow = color.New(color.FgYellow).SprintFunc()
- // Gray is a function that, given a string, returns the string
- // in ANSI gray foreground color.
- var Gray = color.New(color.FgHiBlack).SprintFunc()
|