add a SetReportCaller on Logger object

This commit is contained in:
David Bariod 2018-10-27 15:19:06 +02:00
parent 64d5b7e66c
commit 5fcd19eae6
2 changed files with 7 additions and 3 deletions

View File

@ -27,9 +27,7 @@ func SetFormatter(formatter Formatter) {
// SetReportCaller sets whether the standard logger will include the calling // SetReportCaller sets whether the standard logger will include the calling
// method as a field. // method as a field.
func SetReportCaller(include bool) { func SetReportCaller(include bool) {
std.mu.Lock() std.SetReportCaller(include)
defer std.mu.Unlock()
std.ReportCaller = include
} }
// SetLevel sets the standard logger level. // SetLevel sets the standard logger level.

View File

@ -399,6 +399,12 @@ func (logger *Logger) SetOutput(output io.Writer) {
logger.Out = output 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 // ReplaceHooks replaces the logger hooks and returns the old ones
func (logger *Logger) ReplaceHooks(hooks LevelHooks) LevelHooks { func (logger *Logger) ReplaceHooks(hooks LevelHooks) LevelHooks {
logger.mu.Lock() logger.mu.Lock()