First cut at adding calling method

If log.SetReportMethod(true) then method=PACKAGE.FUNCTION will be added
as a field to log lines.
eg: time="2016-11-25T19:04:43-08:00" level=info method=main msg="log
testing"

TODO: documentation, examples
This commit is contained in:
Dave Clendenan
2016-11-25 19:02:56 -08:00
parent a437dfd246
commit 93af604ba7
10 changed files with 248 additions and 20 deletions
+16
View File
@@ -27,6 +27,22 @@ func SetFormatter(formatter Formatter) {
std.Formatter = formatter
}
// SetReportMethod sets whether to include calling method and line as
// fields
func SetReportMethod(include bool) {
std.mu.Lock()
defer std.mu.Unlock()
std.ReportMethod = include
}
// ReportMethod sets whether to include calling method and line as
// fields
func ReportMethod() bool {
std.mu.Lock()
defer std.mu.Unlock()
return std.ReportMethod
}
// SetLevel sets the standard logger level.
func SetLevel(level Level) {
std.mu.Lock()