Skip to content

Commit

Permalink
Merge pull request #19 from Scalingo/fix/18/plugin-system
Browse files Browse the repository at this point in the history
Use pointer instead of structure as we need to keep the state of data Fixes #18
  • Loading branch information
Soulou authored Nov 11, 2017
2 parents 792fbdb + 37d1808 commit c9d477b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v1.0.1

### logger

* Fix plugin system, use pointer instead of value for manager

## v1.0.0

### mongo (api change)
Expand Down
8 changes: 4 additions & 4 deletions logger/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"github.com/sirupsen/logrus"
)

var plugins = PluginManager{}
var plugins = &PluginManager{}

// Plugins is the entrypoint to the global PluginManager
func Plugins() PluginManager {
func Plugins() *PluginManager {
return plugins
}

Expand All @@ -25,7 +25,7 @@ type PluginManager struct {
}

// RegisterPlugin add a plugin to the current plugin list, if the plugin is already in memory, he will skip the add part
func (m PluginManager) RegisterPlugin(plugin Plugin) {
func (m *PluginManager) RegisterPlugin(plugin Plugin) {
m.lock.Lock()
defer m.lock.Unlock()

Expand All @@ -39,7 +39,7 @@ func (m PluginManager) RegisterPlugin(plugin Plugin) {
}

// Hooks return all the hooks generated by the plugins
func (m PluginManager) Hooks() []logrus.Hook {
func (m *PluginManager) Hooks() []logrus.Hook {
m.lock.Lock()
defer m.lock.Unlock()

Expand Down

0 comments on commit c9d477b

Please sign in to comment.