diff --git a/exported.go b/exported.go index 979582d..7342613 100644 --- a/exported.go +++ b/exported.go @@ -27,9 +27,7 @@ func SetFormatter(formatter Formatter) { // SetReportCaller sets whether the standard logger will include the calling // method as a field. func SetReportCaller(include bool) { - std.mu.Lock() - defer std.mu.Unlock() - std.ReportCaller = include + std.SetReportCaller(include) } // SetLevel sets the standard logger level. diff --git a/logger.go b/logger.go index 68fca98..5ceca0e 100644 --- a/logger.go +++ b/logger.go @@ -399,6 +399,12 @@ func (logger *Logger) SetOutput(output io.Writer) { logger.Out = output } +func (logger *Logger) SetReportCaller(reportCaller bool) { + logger.mu.Lock() + defer logger.mu.Unlock() + logger.ReportCaller = reportCaller +} + // ReplaceHooks replaces the logger hooks and returns the old ones func (logger *Logger) ReplaceHooks(hooks LevelHooks) LevelHooks { logger.mu.Lock()