From c46c01c11689fa240dc70483f00ffb10dab9141f Mon Sep 17 00:00:00 2001 From: Dom Narducci Date: Fri, 25 Oct 2019 13:51:29 -0700 Subject: [PATCH] Log callback registration if logger exists for consistency --- callback.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/callback.go b/callback.go index 4d8e72c0..56b2064a 100644 --- a/callback.go +++ b/callback.go @@ -101,6 +101,12 @@ func (cp *CallbackProcessor) Register(callbackName string, callback func(scope * } } + if cp.logger != nil { + // note cp.logger will be nil during the default gorm callback registrations + // as they occur within init() blocks. However, any user-registered callbacks + // will happen after cp.logger exists (as the default logger or user-specified). + cp.logger.Print("info", fmt.Sprintf("[info] registering callback `%v` from %v", callbackName, fileWithLineNum())) + } cp.name = callbackName cp.processor = &callback cp.parent.processors = append(cp.parent.processors, cp)