diff --git a/go.mod b/go.mod index ea59aaa23425e94de612a9ad00f427b418d87100..e07f8c2e3e59ed7efa7cdfd91ea1d4ce07a81c17 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/go-zeromq/zmq4 v0.7.0 github.com/golang/protobuf v1.3.2 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/hive.go v0.0.0-20200107124343-d0fddfc88dea + github.com/iotaledger/hive.go v0.0.0-20200107205115-986a54f82a30 github.com/iotaledger/iota.go v1.0.0-beta.13 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.3.0 // indirect @@ -31,15 +31,11 @@ require ( github.com/stretchr/objx v0.2.0 // indirect github.com/stretchr/testify v1.4.0 github.com/valyala/fasttemplate v1.1.0 // indirect - go.uber.org/atomic v1.5.1 // indirect - go.uber.org/multierr v1.4.0 // indirect go.uber.org/zap v1.13.0 golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876 - golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8 // indirect - golang.org/x/tools v0.0.0-20191230181014-9fb4d21460e1 // indirect golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect gopkg.in/ini.v1 v1.51.1 // indirect gopkg.in/yaml.v2 v2.2.7 // indirect diff --git a/go.sum b/go.sum index c70612451b8fe7b29bbb14d8afd5ae937e309aee..4f7c64308f02fa91e9857db754580790fac71bae 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= @@ -82,8 +83,8 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iotaledger/hive.go v0.0.0-20200107124343-d0fddfc88dea h1:kLGh9F6KOOygmJPynFSgy7DSlFOg4/x5jmOMOF8vFaA= -github.com/iotaledger/hive.go v0.0.0-20200107124343-d0fddfc88dea/go.mod h1:vrZrvGaWT1o5kz3Jj2B/PcUtqsFzZnLWrO3zEsGSuwk= +github.com/iotaledger/hive.go v0.0.0-20200107205115-986a54f82a30 h1:eE0sEnnQ/HV7QtkUBEPFXPqMXPjUET2UIWDCDcUuGhk= +github.com/iotaledger/hive.go v0.0.0-20200107205115-986a54f82a30/go.mod h1:obs07gqna53/Yw1ltzLsQzJBMyA6lGu7Fb/ltjqWMnQ= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/iotaledger/iota.go v1.0.0-beta.13 h1:6m6JRcKtjTflU2PbjvDA9Tv6NTEJX1PijBDOkH9weQc= github.com/iotaledger/iota.go v1.0.0-beta.13/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= @@ -141,6 +142,7 @@ github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCr github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= @@ -192,6 +194,7 @@ github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= @@ -285,8 +288,8 @@ golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191230181014-9fb4d21460e1 h1:vNFL7Do+hbqZGmVjqkjTBUugGFXohWPyiHMLqLUbtP4= -golang.org/x/tools v0.0.0-20191230181014-9fb4d21460e1/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114 h1:DnSr2mCsxyCE6ZgIkmcWUQY2R5cH/6wL7eIxEmQOMSE= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= diff --git a/main.go b/main.go index 54e57babf90e9eea570540de703e384a7bda287e..64789962bb42b933152631a6d82f9047c715a6b8 100644 --- a/main.go +++ b/main.go @@ -28,6 +28,8 @@ import ( ) func main() { + cli.LoadConfig() + go http.ListenAndServe("localhost:6060", nil) // pprof Server for Debbuging Mutexes node.Run( diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go index 8767c14a89090dd3c50e9a22645f4b9ba562d5ee..a2cae4aefa4b3ae824008dc44cc8332bc13c9b86 100644 --- a/packages/transactionspammer/transactionspammer.go +++ b/packages/transactionspammer/transactionspammer.go @@ -14,7 +14,7 @@ import ( "github.com/iotaledger/hive.go/logger" ) -var log = logger.NewLogger("Transaction Spammer") +var log *logger.Logger var spamming = false var spammingMutex sync.Mutex @@ -30,6 +30,7 @@ func init() { } func Start(tps uint) { + log = logger.NewLogger("Transaction Spammer") spammingMutex.Lock() spamming = true spammingMutex.Unlock() @@ -59,7 +60,7 @@ func Start(tps uint) { tx.SetTrunkTransactionHash(tipselection.GetRandomTip()) tx.SetTimestamp(uint(time.Now().Unix())) if err := tx.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE); err != nil { - log.Warning("PoW failed", err) + log.Warn("PoW failed", err) continue } diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index 1dd3054876999f2d540c5aed9c11cc68662da274..da700fadeab250016a45421f3344e888141d9d77 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -23,9 +23,10 @@ import ( "github.com/iotaledger/hive.go/timeutil" ) -var log = logger.NewLogger("Analysis-Client") +var log *logger.Logger func Run(plugin *node.Plugin) { + log = logger.NewLogger("Analysis-Client") daemon.BackgroundWorker("Analysis Client", func(shutdownSignal <-chan struct{}) { shuttingDown := false diff --git a/plugins/analysis/plugin.go b/plugins/analysis/plugin.go index 0208ca1d915ff881849159c7402d4103dd3350e3..8be4a8422f10dff034cc7d90d793361115cf1243 100644 --- a/plugins/analysis/plugin.go +++ b/plugins/analysis/plugin.go @@ -10,9 +10,10 @@ import ( ) var PLUGIN = node.NewPlugin("Analysis", node.Enabled, configure, run) -var log = logger.NewLogger("Analysis") +var log *logger.Logger func configure(plugin *node.Plugin) { + log = logger.NewLogger("Analysis") if parameter.NodeConfig.GetInt(server.CFG_SERVER_PORT) != 0 { webinterface.Configure(plugin) server.Configure(plugin) diff --git a/plugins/analysis/server/plugin.go b/plugins/analysis/server/plugin.go index 40fabc28ac500b4d1203f3d0aa5e0232b10b5c08..35973f84a6fb701a4c1001c234750c6b004f41eb 100644 --- a/plugins/analysis/server/plugin.go +++ b/plugins/analysis/server/plugin.go @@ -21,9 +21,10 @@ import ( var server *tcp.Server -var log = logger.NewLogger("Analysis-Server") +var log *logger.Logger func Configure(plugin *node.Plugin) { + log = logger.NewLogger("Analysis-Server") server = tcp.NewServer() server.Events.Connect.Attach(events.NewClosure(HandleConnection)) diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index 4ba57d0c0ee1a21ebb288c403977add4f2a081b1..1952d5c7d9c9de41d4f540d1020ef5eaa8d87ccb 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -16,9 +16,11 @@ const ( var PLUGIN = node.NewPlugin(name, node.Enabled, configure, run) -var log = logger.NewLogger(name) +var log *logger.Logger func configure(*node.Plugin) { + log = logger.NewLogger(name) + configureEvents() configureAP() } diff --git a/plugins/bundleprocessor/plugin.go b/plugins/bundleprocessor/plugin.go index c95eeeed59c95ed7cd85cb82dc72f1278cf994c6..0f013307ae34e8de1e86d1006dfbd3adfce4badf 100644 --- a/plugins/bundleprocessor/plugin.go +++ b/plugins/bundleprocessor/plugin.go @@ -11,9 +11,10 @@ import ( ) var PLUGIN = node.NewPlugin("Bundle Processor", node.Enabled, configure, run) -var log = logger.NewLogger("Bundle Processor") +var log *logger.Logger func configure(plugin *node.Plugin) { + log = logger.NewLogger("Bundle Processor") tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { if tx.IsHead() { workerPool.Submit(tx) diff --git a/plugins/cli/plugin.go b/plugins/cli/plugin.go index d4da0e2a5cc617f3bf6a55d608549774816337d3..fe3bbc0aa2ca42daa381dab19878fb1d0bbf2a20 100644 --- a/plugins/cli/plugin.go +++ b/plugins/cli/plugin.go @@ -6,6 +6,7 @@ import ( "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" flag "github.com/spf13/pflag" ) @@ -43,6 +44,17 @@ func parseParameters() { } } +func LoadConfig(){ + if err := parameter.FetchConfig(true); err != nil { + panic(err) + } + parseParameters() + + if err := logger.InitGlobalLogger(parameter.NodeConfig); err != nil { + panic(err) + } +} + func configure(ctx *node.Plugin) { fmt.Println(" _____ _ _ ________ ______ ___ ___________ ") @@ -53,11 +65,6 @@ func configure(ctx *node.Plugin) { fmt.Printf(" \\____/\\_| |_/\\___/\\_| |_/\\_| |_/\\____/\\_| \\_| fullnode %s", AppVersion) fmt.Println() - if err := parameter.FetchConfig(true); err != nil { - panic(err) - } - parseParameters() - ctx.Node.Logger.Info("Loading plugins ...") } diff --git a/plugins/dashboard/plugin.go b/plugins/dashboard/plugin.go index f263b4b88a1daae71811f16fa8c92c85e52e665e..4321e0b5c5f452fbb6498d400eb925f14107646e 100644 --- a/plugins/dashboard/plugin.go +++ b/plugins/dashboard/plugin.go @@ -17,9 +17,10 @@ var server *http.Server var router *http.ServeMux var PLUGIN = node.NewPlugin("Dashboard", node.Disabled, configure, run) -var log = logger.NewLogger("Dashboard") +var log *logger.Logger func configure(plugin *node.Plugin) { + log = logger.NewLogger("Dashboard") router = http.NewServeMux() server = &http.Server{Addr: ":8081", Handler: router} diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index 56babd44a2fcfc67027ec4f465d3f685d8037cc7..2c6d6a8d0cdba30f25f3d010fb6147678088c321 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -20,9 +20,10 @@ const ( var PLUGIN = node.NewPlugin(name, node.Enabled, configure, run) -var log = logger.NewLogger(name) +var log *logger.Logger func configure(*node.Plugin) { + log = logger.NewLogger(name) configureGossip() configureEvents() } diff --git a/plugins/gracefulshutdown/plugin.go b/plugins/gracefulshutdown/plugin.go index 15d5cbe64641dd81d08a59b4e10d2fe692f8ae55..2cc523798146b0c67d1686595e7a51e5484c3a66 100644 --- a/plugins/gracefulshutdown/plugin.go +++ b/plugins/gracefulshutdown/plugin.go @@ -15,8 +15,10 @@ import ( // maximum amount of time to wait for background processes to terminate. After that the process is killed. const WAIT_TO_KILL_TIME_IN_SECONDS = 10 -var log = logger.NewLogger("Graceful Shutdown") +var log *logger.Logger + var PLUGIN = node.NewPlugin("Graceful Shutdown", node.Enabled, func(plugin *node.Plugin) { + log = logger.NewLogger("Graceful Shutdown") gracefulStop := make(chan os.Signal) signal.Notify(gracefulStop, syscall.SIGTERM) @@ -25,7 +27,7 @@ var PLUGIN = node.NewPlugin("Graceful Shutdown", node.Enabled, func(plugin *node go func() { <-gracefulStop - log.Warningf("Received shutdown request - waiting (max %d) to finish processing ...", WAIT_TO_KILL_TIME_IN_SECONDS) + log.Warnf("Received shutdown request - waiting (max %d) to finish processing ...", WAIT_TO_KILL_TIME_IN_SECONDS) go func() { start := time.Now() @@ -38,7 +40,7 @@ var PLUGIN = node.NewPlugin("Graceful Shutdown", node.Enabled, func(plugin *node if len(runningBackgroundWorkers) >= 1 { processList = "(" + strings.Join(runningBackgroundWorkers, ", ") + ") " } - log.Warningf("Received shutdown request - waiting (max %d seconds) to finish processing %s...", WAIT_TO_KILL_TIME_IN_SECONDS-int(secondsSinceStart), processList) + log.Warnf("Received shutdown request - waiting (max %d seconds) to finish processing %s...", WAIT_TO_KILL_TIME_IN_SECONDS-int(secondsSinceStart), processList) } else { log.Error("Background processes did not terminate in time! Forcing shutdown ...") os.Exit(1) diff --git a/plugins/statusscreen/logger.go b/plugins/statusscreen/logger.go index 871472bf483435fd7eaa0107780acd9e1564eeff..5d9d780b24f3135a27bca7ec3a24c755b8b125b7 100644 --- a/plugins/statusscreen/logger.go +++ b/plugins/statusscreen/logger.go @@ -6,7 +6,7 @@ import ( "github.com/iotaledger/hive.go/logger" ) -func storeStatusMessage(logLevel logger.LogLevel, prefix string, message string) { +func storeStatusMessage(logLevel logger.Level, prefix string, message string) { mutex.Lock() defer mutex.Unlock() messageLog = append(messageLog, &StatusMessage{ diff --git a/plugins/statusscreen/status_message.go b/plugins/statusscreen/status_message.go index 96ae34ee95e6ad8cbbd38e5253ef366e6f21626f..2ec23aff1dd3bd3c4c935e986c8c13d370b2cfc7 100644 --- a/plugins/statusscreen/status_message.go +++ b/plugins/statusscreen/status_message.go @@ -8,7 +8,7 @@ import ( type StatusMessage struct { Source string - LogLevel logger.LogLevel + LogLevel logger.Level Message string Time time.Time } diff --git a/plugins/statusscreen/statusscreen.go b/plugins/statusscreen/statusscreen.go index e488b59ac4510acd94cc3fce2e54597aaec62a0d..0d51af1e13869886815b206082fc0fa841f5db93 100644 --- a/plugins/statusscreen/statusscreen.go +++ b/plugins/statusscreen/statusscreen.go @@ -1,7 +1,6 @@ package statusscreen import ( - "io/ioutil" "os" "sync" "time" @@ -26,19 +25,14 @@ func configure(plugin *node.Plugin) { return } - // don't write anything to stdout anymore - // as log messages are now stored and displayed via this plugin - logger.InjectWriters(ioutil.Discard) - // store any log message for display - anyLogMsgClosure := events.NewClosure(func(logLevel logger.LogLevel, prefix string, msg string) { + anyLogMsgClosure := events.NewClosure(func(logLevel logger.Level, prefix string, msg string) { storeStatusMessage(logLevel, prefix, msg) }) logger.Events.AnyMsg.Attach(anyLogMsgClosure) daemon.BackgroundWorker("UI-Detach", func(shutdownSignal <-chan struct{}) { <-shutdownSignal - logger.InjectWriters(os.Stdout) logger.Events.AnyMsg.Detach(anyLogMsgClosure) if app != nil { app.Stop() diff --git a/plugins/statusscreen/ui_log_entry.go b/plugins/statusscreen/ui_log_entry.go index fc8db3a76d581ea0466cf32f7c569f6b2522f483..4134636d1d48a71efe2a1d1d3060aec4866e2560 100644 --- a/plugins/statusscreen/ui_log_entry.go +++ b/plugins/statusscreen/ui_log_entry.go @@ -39,16 +39,12 @@ func NewUILogEntry(message StatusMessage) *UILogEntry { switch message.LogLevel { case logger.LevelInfo: fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [blue::d]INFO [black::d]]") - case logger.LevelNotice: - fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [blue::d]NOTICE [black::d]]") - case logger.LevelWarning: + case logger.LevelWarn: fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [yellow::d]WARN [black::d]]") textColor = "yellow::d" case logger.LevelError: fallthrough - case logger.LevelCritical: - fallthrough case logger.LevelPanic: fallthrough case logger.LevelFatal: diff --git a/plugins/tangle/plugin.go b/plugins/tangle/plugin.go index 62006c6be990ea0ef7f8465906706bab07bace40..020480129d218141b376e2815c91a6cc41e80bdf 100644 --- a/plugins/tangle/plugin.go +++ b/plugins/tangle/plugin.go @@ -8,9 +8,10 @@ import ( // region plugin module setup ////////////////////////////////////////////////////////////////////////////////////////// var PLUGIN = node.NewPlugin("Tangle", node.Enabled, configure, run) -var log = logger.NewLogger("Tangle") +var log *logger.Logger func configure(plugin *node.Plugin) { + log = logger.NewLogger("Tangle") configureTransactionDatabase(plugin) configureTransactionMetaDataDatabase(plugin) configureApproversDatabase(plugin) diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index af7b07c525bde46ee7cf1b047aa300b129b09ac6..696bd3d03b7b6ed6c31da36c13f776e1c2427fad 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -38,7 +38,7 @@ func configureSolidifier(plugin *node.Plugin) { gossip.Events.TransactionReceived.Attach(events.NewClosure(func(ev *gossip.TransactionReceivedEvent) { metaTx := meta_transaction.FromBytes(ev.Data) if err := metaTx.Validate(); err != nil { - log.Warningf("invalid transaction: %s", err) + log.Warnf("invalid transaction: %s", err) return } diff --git a/plugins/ui/logger.go b/plugins/ui/logger.go index 08658c431719479887e08ce781c14bd9bf094330..cf488427123718f9de240d1cf2568874a12891eb 100644 --- a/plugins/ui/logger.go +++ b/plugins/ui/logger.go @@ -11,15 +11,15 @@ var logMutex = sync.RWMutex{} var logHistory = make([]*statusMessage, 0) type statusMessage struct { - Source string `json:"source"` - Level logger.LogLevel `json:"level"` - Message string `json:"message"` - Time time.Time `json:"time"` + Source string `json:"source"` + Level logger.Level `json:"level"` + Message string `json:"message"` + Time time.Time `json:"time"` } type resp map[string]interface{} -func storeAndSendStatusMessage(logLevel logger.LogLevel, pluginName string, message string) { +func storeAndSendStatusMessage(logLevel logger.Level, pluginName string, message string) { msg := &statusMessage{ Source: pluginName, diff --git a/plugins/ui/ui.go b/plugins/ui/ui.go index 02e248a3f64db98bf952866213b183de52262f60..f4458e58434f2c4339da661c6c043f043c4623fd 100644 --- a/plugins/ui/ui.go +++ b/plugins/ui/ui.go @@ -50,7 +50,7 @@ func configure(plugin *node.Plugin) { })) // store log messages to send them down via the websocket - anyMsgClosure := events.NewClosure(func(logLvl logger.LogLevel, prefix string, msg string) { + anyMsgClosure := events.NewClosure(func(logLvl logger.Level, prefix string, msg string) { storeAndSendStatusMessage(logLvl, prefix, msg) }) logger.Events.AnyMsg.Attach(anyMsgClosure) diff --git a/plugins/validator/plugin.go b/plugins/validator/plugin.go index 11217efc4604fd3394e940ed5256b9bbe3c0d32f..b20ba75d573100fd0e10af65600a0f3a0871366d 100644 --- a/plugins/validator/plugin.go +++ b/plugins/validator/plugin.go @@ -13,7 +13,7 @@ import ( ) var PLUGIN = node.NewPlugin("Validator", node.Enabled, configure, run) -var log = logger.NewLogger("Validator") +var log *logger.Logger func validateSignatures(bundleHash Hash, txs []*value_transaction.ValueTransaction) (bool, error) { for i, tx := range txs { @@ -51,7 +51,7 @@ func validateSignatures(bundleHash Hash, txs []*value_transaction.ValueTransacti } func configure(plugin *node.Plugin) { - + log = logger.NewLogger("Validator") bundleprocessor.Events.BundleSolid.Attach(events.NewClosure(func(b *bundle.Bundle, txs []*value_transaction.ValueTransaction) { // signature are verified against the bundle hash valid, err := validateSignatures(b.GetBundleEssenceHash(), txs) diff --git a/plugins/webapi-send-data/plugin.go b/plugins/webapi-send-data/plugin.go index 778a41b27b1deae8f5d88c0e8b9a21dd3f64f9d9..c7029181b5a0e7aa8b987e53b28bca9dbc6b9461 100644 --- a/plugins/webapi-send-data/plugin.go +++ b/plugins/webapi-send-data/plugin.go @@ -18,9 +18,10 @@ import ( ) var PLUGIN = node.NewPlugin("WebAPI SendData Endpoint", node.Enabled, configure) -var log = logger.NewLogger("API-sendData") +var log *logger.Logger func configure(plugin *node.Plugin) { + log = logger.NewLogger("API-sendData") webapi.AddEndpoint("sendData", SendDataHandler) } @@ -55,7 +56,7 @@ func SendDataHandler(c echo.Context) error { tx.SetTrunkTransactionHash(tipselection.GetRandomTip()) tx.SetTimestamp(uint(time.Now().Unix())) if err := tx.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE); err != nil { - log.Warning("PoW failed", err) + log.Warn("PoW failed", err) } gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: tx.GetBytes(), Peer: &local.GetInstance().Peer}) diff --git a/plugins/webapi-tx-request/plugin.go b/plugins/webapi-tx-request/plugin.go index a10ac0eada32f1e84602d5a61632052be6084d2a..5f4e4282548acacebab17b8c3b6f4ebd12b4c938 100644 --- a/plugins/webapi-tx-request/plugin.go +++ b/plugins/webapi-tx-request/plugin.go @@ -12,9 +12,10 @@ import ( ) var PLUGIN = node.NewPlugin("WebAPI Transaction Request Endpoint", node.Enabled, configure) -var log = logger.NewLogger("API-TxRequest") +var log *logger.Logger func configure(plugin *node.Plugin) { + log = logger.NewLogger("API-TxRequest") webapi.AddEndpoint("txRequest", Handler) } diff --git a/plugins/webapi/plugin.go b/plugins/webapi/plugin.go index e7d7c5a32fc1478c5fa59d25cd1251dc9c16bfb3..6cd2e037b3f6ad471df85dbe1b40dce0c50d17dd 100644 --- a/plugins/webapi/plugin.go +++ b/plugins/webapi/plugin.go @@ -11,11 +11,12 @@ import ( ) var PLUGIN = node.NewPlugin("WebAPI", node.Enabled, configure, run) -var log = logger.NewLogger("WebAPI") +var log *logger.Logger var Server = echo.New() func configure(plugin *node.Plugin) { + log = logger.NewLogger("WebAPI") Server.HideBanner = true Server.HidePort = true Server.GET("/", IndexRequest) diff --git a/plugins/zeromq/plugin.go b/plugins/zeromq/plugin.go index c9d469a85a6df97ec4b38379062a90447e1f58f6..11ddb33c23927cc873e6a8ff2d83e0288cd194d5 100644 --- a/plugins/zeromq/plugin.go +++ b/plugins/zeromq/plugin.go @@ -16,12 +16,13 @@ import ( // zeromq logging is disabled by default var PLUGIN = node.NewPlugin("ZeroMQ", node.Disabled, configure, run) -var log = logger.NewLogger("ZeroMQ") +var log *logger.Logger var publisher *Publisher var emptyTag = strings.Repeat("9", 27) // Configure the zeromq plugin func configure(plugin *node.Plugin) { + log = logger.NewLogger("ZeroMQ") tangle.Events.TransactionStored.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { // create goroutine for every event go func() {