Roy Crihfield
bc3a7934cf
* refactor vulcanize => cerc * update geth and cerc dependencies * update packages, ginkgo * refactor chain generation * update integration tests, contract, makefile * go embed contract code * rm old readme * move unit tests into package * rm ginkgo where not needed * use tx in ref integrity functions
36 lines
729 B
Go
36 lines
729 B
Go
package cmd
|
|
|
|
import (
|
|
"os"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func ParseLogFlags() {
|
|
logfile := viper.GetString("log.file")
|
|
if logfile != "" {
|
|
file, err := os.OpenFile(logfile,
|
|
os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
|
if err == nil {
|
|
log.Infof("Directing output to %s", logfile)
|
|
log.SetOutput(file)
|
|
} else {
|
|
log.SetOutput(os.Stdout)
|
|
log.Info("Failed to log to file, using default stdout")
|
|
}
|
|
} else {
|
|
log.SetOutput(os.Stdout)
|
|
}
|
|
|
|
lvl, err := log.ParseLevel(viper.GetString("log.level"))
|
|
if err != nil {
|
|
log.Fatal("Could not parse log level: ", err)
|
|
}
|
|
log.SetLevel(lvl)
|
|
if lvl > log.InfoLevel {
|
|
log.SetReportCaller(true)
|
|
}
|
|
log.Info("Log level set to ", lvl)
|
|
}
|