Matthias Andreas Benkard | 832a54e | 2019-01-29 09:27:38 +0100 | [diff] [blame] | 1 | package restful |
| 2 | |
| 3 | // Copyright 2014 Ernest Micklei. All rights reserved. |
| 4 | // Use of this source code is governed by a license |
| 5 | // that can be found in the LICENSE file. |
| 6 | import ( |
| 7 | "github.com/emicklei/go-restful/log" |
| 8 | ) |
| 9 | |
| 10 | var trace bool = false |
| 11 | var traceLogger log.StdLogger |
| 12 | |
| 13 | func init() { |
| 14 | traceLogger = log.Logger // use the package logger by default |
| 15 | } |
| 16 | |
| 17 | // TraceLogger enables detailed logging of Http request matching and filter invocation. Default no logger is set. |
| 18 | // You may call EnableTracing() directly to enable trace logging to the package-wide logger. |
| 19 | func TraceLogger(logger log.StdLogger) { |
| 20 | traceLogger = logger |
| 21 | EnableTracing(logger != nil) |
| 22 | } |
| 23 | |
| 24 | // SetLogger exposes the setter for the global logger on the top-level package |
| 25 | func SetLogger(customLogger log.StdLogger) { |
| 26 | log.SetLogger(customLogger) |
| 27 | } |
| 28 | |
| 29 | // EnableTracing can be used to Trace logging on and off. |
| 30 | func EnableTracing(enabled bool) { |
| 31 | trace = enabled |
| 32 | } |