github.com/joey-fossa/fossa-cli@v0.7.34-0.20190708193710-569f1e8679f0/cmd/fossa/display/display.go (about) 1 // Package display implements functions for displaying output to users. 2 package display 3 4 import ( 5 "io/ioutil" 6 "os" 7 "time" 8 9 "github.com/apex/log" 10 "github.com/briandowns/spinner" 11 ) 12 13 var ( 14 file *os.File 15 s *spinner.Spinner 16 useANSI bool 17 level log.Level 18 ) 19 20 func init() { 21 // Set up spinner. 22 s = spinner.New(spinner.CharSets[11], 100*time.Millisecond) 23 s.Writer = os.Stderr 24 25 // Set up log file. 26 f, err := ioutil.TempFile("", "fossa-cli.*.log") 27 if err != nil { 28 log.WithError(err).Warnf("could not open log file") 29 } 30 file = f 31 32 // Set up log handler. 33 // Always set the logging package to debug, otherwise we lose the debug 34 // entries that we would write to the log file. 35 log.SetLevel(log.DebugLevel) 36 log.SetHandler(log.HandlerFunc(Handler)) 37 // TODO: we do this because we log while reading files in `config.SetContext`, 38 // but we really should only read files lazily. 39 level = log.InfoLevel 40 }