From 9c7ff3d211628a73b29032a5d8a6564b3f72ed3e Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 1 Sep 2014 17:32:11 +0800 Subject: [PATCH] Don't show duplicated replacing callback message --- callback.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/callback.go b/callback.go index fa8b4822..b82efd8f 100644 --- a/callback.go +++ b/callback.go @@ -66,12 +66,14 @@ func (cp *callback_processor) Register(name string, fc func(scope *Scope)) { } func (cp *callback_processor) Remove(name string) { + fmt.Printf("[info] removing callback `%v` from %v\n", cp.name, fileWithLineNum()) cp.name = name cp.remove = true cp.callback.sort() } func (cp *callback_processor) Replace(name string, fc func(scope *Scope)) { + fmt.Printf("[info] replacing callback `%v` from %v\n", cp.name, fileWithLineNum()) cp.name = name cp.processor = &fc cp.replace = true @@ -93,11 +95,7 @@ func sortProcessors(cps []*callback_processor) []*func(scope *Scope) { for _, cp := range cps { if index := getRIndex(names, cp.name); index > -1 { - if cp.replace { - fmt.Printf("[info] replacing callback `%v` from %v\n", cp.name, fileWithLineNum()) - } else if cp.remove { - fmt.Printf("[info] removing callback `%v` from %v\n", cp.name, fileWithLineNum()) - } else { + if !cp.replace && !cp.remove { fmt.Printf("[warning] duplicated callback `%v` from %v\n", cp.name, fileWithLineNum()) } }