github.com/craigmonson/colonize@v0.1.1-alpha.0.20170808202020-04bf903fb1ea/log/log.go (about)

     1  package log
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/fatih/color"
     7  )
     8  
     9  type Logger interface {
    10  	Log(string)
    11  	Print(string)
    12  	LogPretty(string, ...color.Attribute)
    13  	PrintPretty(string, ...color.Attribute)
    14  }
    15  
    16  type Log struct {
    17  	Logger
    18  }
    19  
    20  func (l Log) Log(s string) {
    21  	fmt.Println(s)
    22  }
    23  
    24  func (l Log) Print(s string) {
    25  	fmt.Print(s)
    26  }
    27  
    28  func (l Log) LogPretty(s string, p ...color.Attribute) {
    29  	color.Set(p...)
    30  	l.Log(s)
    31  	color.Unset()
    32  }
    33  
    34  func (l Log) PrintPretty(s string, p ...color.Attribute) {
    35  	color.Set(p...)
    36  	l.Print(s)
    37  	color.Unset()
    38  }