Skip to content

Commit

Permalink
Warn only once about the legacy logger usage (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislas-m committed Sep 18, 2018
1 parent 4d73fa6 commit 5741ca3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
stdlog "log"
"os"
"sync"

"github.com/fatih/color"
"github.com/gobuffalo/pop/logging"
Expand All @@ -24,7 +25,9 @@ var defaultStdLogger = stdlog.New(os.Stdout, "[POP] ", stdlog.LstdFlags)
var defaultLogger = func(lvl logging.Level, s string, args ...interface{}) {
// Handle legacy logger
if Log != nil {
fmt.Println("Warning: Log is deprecated, and will be removed in a future version. Please use SetLogger instead.")
legacyLoggerOnce.Do(func() {
fmt.Println("Warning: Log is deprecated, and will be removed in a future version. Please use SetLogger instead.")
})
Log(s, args...)
return
}
Expand Down Expand Up @@ -67,3 +70,4 @@ func SetLogger(l logger) {
// Log defines the pop logger. Override it to customize pop logs handling.
// Deprecated: use SetLogger instead
var Log legacyLogger
var legacyLoggerOnce = sync.Once{}

0 comments on commit 5741ca3

Please sign in to comment.