-
Notifications
You must be signed in to change notification settings - Fork 113
/
plugin.go
37 lines (30 loc) · 906 Bytes
/
plugin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package logger
import (
"go.uber.org/dig"
"github.com/iotaledger/hive.go/configuration"
"github.com/iotaledger/hive.go/daemon"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/node"
)
// PluginName is the name of the logger plugin.
const PluginName = "Logger"
// Plugin is the plugin instance of the logger plugin.
var Plugin = node.NewPlugin(PluginName, nil, node.Enabled)
// Init triggers the Init event.
func Init() {
Plugin.Events.Init.Trigger(Plugin)
}
func init() {
Plugin.Events.Init.Attach(events.NewClosure(func(_ *node.Plugin, container *dig.Container) {
if err := container.Invoke(func(config *configuration.Configuration) {
if err := logger.InitGlobalLogger(config); err != nil {
panic(err)
}
}); err != nil {
Plugin.Panic(err)
}
// enable logging for the daemon
daemon.DebugEnabled(true)
}))
}