Skip to content
Snippets Groups Projects
Commit c9c372b1 authored by Hans Moog's avatar Hans Moog
Browse files

Feat: added option to disable plugins + control log level

parent ddb4aae6
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ package node ...@@ -3,6 +3,7 @@ package node
import ( import (
"fmt" "fmt"
"github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/daemon"
"strings"
"sync" "sync"
) )
...@@ -13,7 +14,13 @@ type Node struct { ...@@ -13,7 +14,13 @@ type Node struct {
logLevel int logLevel int
} }
var disabledPlugins = make(map[string]bool)
func Load(plugins ...*Plugin) *Node { func Load(plugins ...*Plugin) *Node {
for _, disabledPlugin := range strings.Fields(*DISABLE_PLUGINS.Value) {
disabledPlugins[strings.ToLower(disabledPlugin)] = true
}
fmt.Println(" _____ _ _ ________ ______ ___ ___________ ") fmt.Println(" _____ _ _ ________ ______ ___ ___________ ")
fmt.Println(" / ___| | | |_ _| \\/ || \\/ || ___| ___ \\") fmt.Println(" / ___| | | |_ _| \\/ || \\/ || ___| ___ \\")
fmt.Println(" \\ `--.| |_| | | | | . . || . . || |__ | |_/ /") fmt.Println(" \\ `--.| |_| | | | | . . || . . || |__ | |_/ /")
...@@ -23,7 +30,7 @@ func Load(plugins ...*Plugin) *Node { ...@@ -23,7 +30,7 @@ func Load(plugins ...*Plugin) *Node {
fmt.Println() fmt.Println()
node := &Node{ node := &Node{
logLevel: LOG_LEVEL_INFO, logLevel: *LOG_LEVEL.Value,
loggers: make([]*Logger, 0), loggers: make([]*Logger, 0),
wg: &sync.WaitGroup{}, wg: &sync.WaitGroup{},
loadedPlugins: make([]*Plugin, 0), loadedPlugins: make([]*Plugin, 0),
...@@ -91,16 +98,23 @@ func (node *Node) Load(plugins ...*Plugin) { ...@@ -91,16 +98,23 @@ func (node *Node) Load(plugins ...*Plugin) {
if len(plugins) >= 1 { if len(plugins) >= 1 {
for _, plugin := range plugins { for _, plugin := range plugins {
plugin.wg = node.wg fmt.Println(*DISABLE_PLUGINS.Value)
plugin.Node = node fmt.Println(disabledPlugins)
fmt.Println(strings.ToLower(strings.Replace(plugin.Name, " ", "", -1)))
if _, exists := disabledPlugins[strings.ToLower(strings.Replace(plugin.Name, " ", "", -1))]; !exists {
plugin.wg = node.wg
plugin.Node = node
plugin.Events.Configure.Trigger(plugin) plugin.Events.Configure.Trigger(plugin)
node.LogInfo("Node", "Loading Plugin: "+plugin.Name+" ... done") node.LogInfo("Node", "Loading Plugin: " + plugin.Name + " ... done")
node.loadedPlugins = append(node.loadedPlugins, plugin)
}
} }
} }
node.loadedPlugins = append(node.loadedPlugins, plugins...) //node.loadedPlugins = append(node.loadedPlugins, plugins...)
} }
func (node *Node) Run() { func (node *Node) Run() {
......
package node
import "github.com/iotaledger/goshimmer/packages/parameter"
var (
LOG_LEVEL = parameter.AddInt("NODE/LOG_LEVEL", LOG_LEVEL_SUCCESS, "controls the log types that are shown")
DISABLE_PLUGINS = parameter.AddString("NODE/DISABLE_PLUGINS", "", "a list of plugins that shall be disabled")
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment