Add calling method to debug level log messages

This commit is contained in:
Andrew J Yao 2019-07-11 16:57:37 -07:00
parent 2c092e8d04
commit d7a82e353b
3 changed files with 8 additions and 5 deletions

View File

@ -75,7 +75,7 @@ func initFuncs(cmd *cobra.Command, args []string) {
}
func database(cmd *cobra.Command, args []string) {
func database() {
ipc = viper.GetString("client.ipcpath")
levelDbPath = viper.GetString("client.leveldbpath")
storageDiffsPath = viper.GetString("filesystem.storageDiffsPath")
@ -89,12 +89,15 @@ func database(cmd *cobra.Command, args []string) {
viper.Set("database.config", databaseConfig)
}
func logLevel(cmd *cobra.Command, args []string) error {
func logLevel() error {
lvl, err := log.ParseLevel(viper.GetString("log.level"))
if err != nil {
return err
}
log.SetLevel(lvl)
if lvl > log.InfoLevel {
log.SetReportCaller(true)
}
log.Info("Log level set to ", lvl.String())
return nil
}

View File

@ -4,4 +4,4 @@
port = 5432
[client]
ipcPath = ""
ipcPath = "https://kovan.infura.io/v3/be5f83b248b74b34890cbf76e0945e29"

View File

@ -3,15 +3,15 @@ package main
import (
"github.com/vulcanize/vulcanizedb/cmd"
log "github.com/sirupsen/logrus"
"os"
log "github.com/sirupsen/logrus"
)
func main() {
log.SetFormatter(&log.JSONFormatter{
PrettyPrint: true,
})
log.SetReportCaller(true)
file, err := os.OpenFile("vulcanizedb.log",
os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err == nil {