瀏覽代碼

Add logger to plugin example

Signed-off-by: Robert Lin <robertlin1@gmail.com>
Robert Lin 6 年之前
父節點
當前提交
5785192bb5
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      contrib/_plugin_example/churn_analysis.go

+ 6 - 0
contrib/_plugin_example/churn_analysis.go

@@ -30,6 +30,8 @@ type ChurnAnalysis struct {
 
 	// references IdentityDetector.ReversedPeopleDict
 	reversedPeopleDict []string
+
+	l hercules.Logger
 }
 
 type editInfo struct {
@@ -105,6 +107,9 @@ func (churn *ChurnAnalysis) Description() string {
 
 // Configure applies the parameters specified in the command line. Map keys correspond to "Name".
 func (churn *ChurnAnalysis) Configure(facts map[string]interface{}) error {
+	if l, exists := facts[hercules.ConfigLogger].(hercules.Logger); exists {
+		churn.l = l
+	}
 	if val, exists := facts[ConfigChurnTrackPeople].(bool); exists {
 		churn.TrackPeople = val
 	}
@@ -116,6 +121,7 @@ func (churn *ChurnAnalysis) Configure(facts map[string]interface{}) error {
 
 // Initialize resets the internal temporary data structures and prepares the object for Consume().
 func (churn *ChurnAnalysis) Initialize(repository *git.Repository) error {
+	churn.l = hercules.NewLogger()
 	churn.global = []editInfo{}
 	churn.people = map[int][]editInfo{}
 	churn.OneShotMergeProcessor.Initialize()