Skip to content

Commit

Permalink
[main] [config] refs fibercrypto#298 - Add log level settings
Browse files Browse the repository at this point in the history
  • Loading branch information
AntiD2ta committed Jan 5, 2020
1 parent 0b39a01 commit b956f08
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/coin/skycoin/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func getMultiPlatformUserDirectory() string {

func RegisterConfig() error {
cm := local.GetConfigManager()
node := map[string]string{"address": "https://staging.node.skycoin.net"}
node := map[string]string{"address": "https://staging.node.skycoin.net", "level": "warn"}
nodeBytes, err := json.Marshal(node)
if err != nil {
return err
Expand All @@ -53,14 +53,14 @@ func RegisterConfig() error {

wltOpt := local.NewOption(string(wltSrc.id), []string{SettingPathToWalletSource}, false, string(wltSrcBytes))

level := map[string]string{"level": "Debug"}
levelBytes, err := json.Marshal(level)
if err != nil {
return err
}
logLevelOpt := local.NewOption(SettingPathToLog, []string{}, false, string(levelBytes))
// level := map[string]string{"level": "warn"}
// levelBytes, err := json.Marshal(level)
// if err != nil {
// return err
// }
// logLevelOpt := local.NewOption(SettingPathToNode, []string{}, false, string(levelBytes))

sectionManager = cm.RegisterSection(SectionName, []*local.Option{nodeOpt, wltOpt, logLevelOpt})
sectionManager = cm.RegisterSection(SectionName, []*local.Option{nodeOpt, wltOpt}) //, logLevelOpt})
return nil
}

Expand Down
23 changes: 23 additions & 0 deletions src/coin/skycoin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ func init() {
if err != nil {
logSkycoin.Warn("Couldn't register Skycoin configuration")
}

// logStr, err := config.GetOption(config.SettingPathToNode)
// if err != nil {
// logSkycoin.Warn("Couldn't get log options")
// logSkycoin.WithError(err).Error("AA")
// }
// log := make(map[string]string)
// err = json.Unmarshal([]byte(logStr), &log)
// if err != nil {
// logSkycoin.Warn("Couldn't unmarshal from options")
// }
// level, err := logging.LevelFromString(log["level"])
// if err != nil {
// logSkycoin.Warn("Couldn't get level from logging " + log["level"])
// }
// logging.SetLevel(level)

nodeStr, err := config.GetOption(config.SettingPathToNode)
if err != nil {
logSkycoin.Warn("Couldn't get node options")
Expand All @@ -29,6 +46,12 @@ func init() {
if err != nil {
logSkycoin.Warn("Couldn't unmarshal from options")
}
level, err := logging.LevelFromString(node["level"])
if err != nil {
logSkycoin.Warn("Couldn't get level from logging")
logSkycoin.WithError(err).WithField("string", node["level"]).Error()
}
logging.SetLevel(level)
err = core.GetMultiPool().CreateSection(sky.PoolSection, sky.NewSkycoinConnectionFactory(node["address"]))
if err != nil {
logSkycoin.Warn("Couldn't create section for Skycoin")
Expand Down

0 comments on commit b956f08

Please sign in to comment.