diff options
Diffstat (limited to 'vendor/github.com/hashicorp/go-hclog')
-rw-r--r-- | vendor/github.com/hashicorp/go-hclog/.gitignore | 1 | ||||
-rw-r--r-- | vendor/github.com/hashicorp/go-hclog/README.md | 14 | ||||
-rw-r--r-- | vendor/github.com/hashicorp/go-hclog/go.mod | 7 | ||||
-rw-r--r-- | vendor/github.com/hashicorp/go-hclog/go.sum | 6 | ||||
-rw-r--r-- | vendor/github.com/hashicorp/go-hclog/int.go | 174 | ||||
-rw-r--r-- | vendor/github.com/hashicorp/go-hclog/log.go | 29 | ||||
-rw-r--r-- | vendor/github.com/hashicorp/go-hclog/nulllogger.go | 47 |
7 files changed, 247 insertions, 31 deletions
diff --git a/vendor/github.com/hashicorp/go-hclog/.gitignore b/vendor/github.com/hashicorp/go-hclog/.gitignore new file mode 100644 index 0000000..42cc410 --- /dev/null +++ b/vendor/github.com/hashicorp/go-hclog/.gitignore | |||
@@ -0,0 +1 @@ | |||
.idea* \ No newline at end of file | |||
diff --git a/vendor/github.com/hashicorp/go-hclog/README.md b/vendor/github.com/hashicorp/go-hclog/README.md index 614342b..1153e28 100644 --- a/vendor/github.com/hashicorp/go-hclog/README.md +++ b/vendor/github.com/hashicorp/go-hclog/README.md | |||
@@ -10,8 +10,7 @@ interface for use in development and production environments. | |||
10 | It provides logging levels that provide decreased output based upon the | 10 | It provides logging levels that provide decreased output based upon the |
11 | desired amount of output, unlike the standard library `log` package. | 11 | desired amount of output, unlike the standard library `log` package. |
12 | 12 | ||
13 | It does not provide `Printf` style logging, only key/value logging that is | 13 | It provides `Printf` style logging of values via `hclog.Fmt()`. |
14 | exposed as arguments to the logging functions for simplicity. | ||
15 | 14 | ||
16 | It provides a human readable output mode for use in development as well as | 15 | It provides a human readable output mode for use in development as well as |
17 | JSON output mode for production. | 16 | JSON output mode for production. |
@@ -100,6 +99,17 @@ requestLogger.Info("we are transporting a request") | |||
100 | This allows sub Loggers to be context specific without having to thread that | 99 | This allows sub Loggers to be context specific without having to thread that |
101 | into all the callers. | 100 | into all the callers. |
102 | 101 | ||
102 | ### Using `hclog.Fmt()` | ||
103 | |||
104 | ```go | ||
105 | var int totalBandwidth = 200 | ||
106 | appLogger.Info("total bandwidth exceeded", "bandwidth", hclog.Fmt("%d GB/s", totalBandwidth)) | ||
107 | ``` | ||
108 | |||
109 | ```text | ||
110 | ... [INFO ] my-app: total bandwidth exceeded: bandwidth="200 GB/s" | ||
111 | ``` | ||
112 | |||
103 | ### Use this with code that uses the standard library logger | 113 | ### Use this with code that uses the standard library logger |
104 | 114 | ||
105 | If you want to use the standard library's `log.Logger` interface you can wrap | 115 | If you want to use the standard library's `log.Logger` interface you can wrap |
diff --git a/vendor/github.com/hashicorp/go-hclog/go.mod b/vendor/github.com/hashicorp/go-hclog/go.mod new file mode 100644 index 0000000..0d079a6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-hclog/go.mod | |||
@@ -0,0 +1,7 @@ | |||
1 | module github.com/hashicorp/go-hclog | ||
2 | |||
3 | require ( | ||
4 | github.com/davecgh/go-spew v1.1.1 // indirect | ||
5 | github.com/pmezard/go-difflib v1.0.0 // indirect | ||
6 | github.com/stretchr/testify v1.2.2 | ||
7 | ) | ||
diff --git a/vendor/github.com/hashicorp/go-hclog/go.sum b/vendor/github.com/hashicorp/go-hclog/go.sum new file mode 100644 index 0000000..e03ee77 --- /dev/null +++ b/vendor/github.com/hashicorp/go-hclog/go.sum | |||
@@ -0,0 +1,6 @@ | |||
1 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
2 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
3 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
4 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
5 | github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= | ||
6 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | ||
diff --git a/vendor/github.com/hashicorp/go-hclog/int.go b/vendor/github.com/hashicorp/go-hclog/int.go index 9f90c28..2aaa1f8 100644 --- a/vendor/github.com/hashicorp/go-hclog/int.go +++ b/vendor/github.com/hashicorp/go-hclog/int.go | |||
@@ -2,14 +2,19 @@ package hclog | |||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "bufio" | 4 | "bufio" |
5 | "bytes" | ||
6 | "encoding" | ||
5 | "encoding/json" | 7 | "encoding/json" |
6 | "fmt" | 8 | "fmt" |
7 | "log" | 9 | "log" |
8 | "os" | 10 | "os" |
11 | "reflect" | ||
9 | "runtime" | 12 | "runtime" |
13 | "sort" | ||
10 | "strconv" | 14 | "strconv" |
11 | "strings" | 15 | "strings" |
12 | "sync" | 16 | "sync" |
17 | "sync/atomic" | ||
13 | "time" | 18 | "time" |
14 | ) | 19 | ) |
15 | 20 | ||
@@ -17,8 +22,8 @@ var ( | |||
17 | _levelToBracket = map[Level]string{ | 22 | _levelToBracket = map[Level]string{ |
18 | Debug: "[DEBUG]", | 23 | Debug: "[DEBUG]", |
19 | Trace: "[TRACE]", | 24 | Trace: "[TRACE]", |
20 | Info: "[INFO ]", | 25 | Info: "[INFO] ", |
21 | Warn: "[WARN ]", | 26 | Warn: "[WARN] ", |
22 | Error: "[ERROR]", | 27 | Error: "[ERROR]", |
23 | } | 28 | } |
24 | ) | 29 | ) |
@@ -39,28 +44,40 @@ func New(opts *LoggerOptions) Logger { | |||
39 | level = DefaultLevel | 44 | level = DefaultLevel |
40 | } | 45 | } |
41 | 46 | ||
42 | return &intLogger{ | 47 | mtx := opts.Mutex |
43 | m: new(sync.Mutex), | 48 | if mtx == nil { |
44 | json: opts.JSONFormat, | 49 | mtx = new(sync.Mutex) |
45 | caller: opts.IncludeLocation, | ||
46 | name: opts.Name, | ||
47 | w: bufio.NewWriter(output), | ||
48 | level: level, | ||
49 | } | 50 | } |
51 | |||
52 | ret := &intLogger{ | ||
53 | m: mtx, | ||
54 | json: opts.JSONFormat, | ||
55 | caller: opts.IncludeLocation, | ||
56 | name: opts.Name, | ||
57 | timeFormat: TimeFormat, | ||
58 | w: bufio.NewWriter(output), | ||
59 | level: new(int32), | ||
60 | } | ||
61 | if opts.TimeFormat != "" { | ||
62 | ret.timeFormat = opts.TimeFormat | ||
63 | } | ||
64 | atomic.StoreInt32(ret.level, int32(level)) | ||
65 | return ret | ||
50 | } | 66 | } |
51 | 67 | ||
52 | // The internal logger implementation. Internal in that it is defined entirely | 68 | // The internal logger implementation. Internal in that it is defined entirely |
53 | // by this package. | 69 | // by this package. |
54 | type intLogger struct { | 70 | type intLogger struct { |
55 | json bool | 71 | json bool |
56 | caller bool | 72 | caller bool |
57 | name string | 73 | name string |
74 | timeFormat string | ||
58 | 75 | ||
59 | // this is a pointer so that it's shared by any derived loggers, since | 76 | // this is a pointer so that it's shared by any derived loggers, since |
60 | // those derived loggers share the bufio.Writer as well. | 77 | // those derived loggers share the bufio.Writer as well. |
61 | m *sync.Mutex | 78 | m *sync.Mutex |
62 | w *bufio.Writer | 79 | w *bufio.Writer |
63 | level Level | 80 | level *int32 |
64 | 81 | ||
65 | implied []interface{} | 82 | implied []interface{} |
66 | } | 83 | } |
@@ -75,7 +92,7 @@ const TimeFormat = "2006-01-02T15:04:05.000Z0700" | |||
75 | // Log a message and a set of key/value pairs if the given level is at | 92 | // Log a message and a set of key/value pairs if the given level is at |
76 | // or more severe that the threshold configured in the Logger. | 93 | // or more severe that the threshold configured in the Logger. |
77 | func (z *intLogger) Log(level Level, msg string, args ...interface{}) { | 94 | func (z *intLogger) Log(level Level, msg string, args ...interface{}) { |
78 | if level < z.level { | 95 | if level < Level(atomic.LoadInt32(z.level)) { |
79 | return | 96 | return |
80 | } | 97 | } |
81 | 98 | ||
@@ -126,14 +143,14 @@ func trimCallerPath(path string) string { | |||
126 | 143 | ||
127 | // Non-JSON logging format function | 144 | // Non-JSON logging format function |
128 | func (z *intLogger) log(t time.Time, level Level, msg string, args ...interface{}) { | 145 | func (z *intLogger) log(t time.Time, level Level, msg string, args ...interface{}) { |
129 | z.w.WriteString(t.Format(TimeFormat)) | 146 | z.w.WriteString(t.Format(z.timeFormat)) |
130 | z.w.WriteByte(' ') | 147 | z.w.WriteByte(' ') |
131 | 148 | ||
132 | s, ok := _levelToBracket[level] | 149 | s, ok := _levelToBracket[level] |
133 | if ok { | 150 | if ok { |
134 | z.w.WriteString(s) | 151 | z.w.WriteString(s) |
135 | } else { | 152 | } else { |
136 | z.w.WriteString("[UNKN ]") | 153 | z.w.WriteString("[?????]") |
137 | } | 154 | } |
138 | 155 | ||
139 | if z.caller { | 156 | if z.caller { |
@@ -174,7 +191,10 @@ func (z *intLogger) log(t time.Time, level Level, msg string, args ...interface{ | |||
174 | 191 | ||
175 | FOR: | 192 | FOR: |
176 | for i := 0; i < len(args); i = i + 2 { | 193 | for i := 0; i < len(args); i = i + 2 { |
177 | var val string | 194 | var ( |
195 | val string | ||
196 | raw bool | ||
197 | ) | ||
178 | 198 | ||
179 | switch st := args[i+1].(type) { | 199 | switch st := args[i+1].(type) { |
180 | case string: | 200 | case string: |
@@ -202,15 +222,23 @@ func (z *intLogger) log(t time.Time, level Level, msg string, args ...interface{ | |||
202 | case CapturedStacktrace: | 222 | case CapturedStacktrace: |
203 | stacktrace = st | 223 | stacktrace = st |
204 | continue FOR | 224 | continue FOR |
225 | case Format: | ||
226 | val = fmt.Sprintf(st[0].(string), st[1:]...) | ||
205 | default: | 227 | default: |
206 | val = fmt.Sprintf("%v", st) | 228 | v := reflect.ValueOf(st) |
229 | if v.Kind() == reflect.Slice { | ||
230 | val = z.renderSlice(v) | ||
231 | raw = true | ||
232 | } else { | ||
233 | val = fmt.Sprintf("%v", st) | ||
234 | } | ||
207 | } | 235 | } |
208 | 236 | ||
209 | z.w.WriteByte(' ') | 237 | z.w.WriteByte(' ') |
210 | z.w.WriteString(args[i].(string)) | 238 | z.w.WriteString(args[i].(string)) |
211 | z.w.WriteByte('=') | 239 | z.w.WriteByte('=') |
212 | 240 | ||
213 | if strings.ContainsAny(val, " \t\n\r") { | 241 | if !raw && strings.ContainsAny(val, " \t\n\r") { |
214 | z.w.WriteByte('"') | 242 | z.w.WriteByte('"') |
215 | z.w.WriteString(val) | 243 | z.w.WriteString(val) |
216 | z.w.WriteByte('"') | 244 | z.w.WriteByte('"') |
@@ -227,6 +255,45 @@ func (z *intLogger) log(t time.Time, level Level, msg string, args ...interface{ | |||
227 | } | 255 | } |
228 | } | 256 | } |
229 | 257 | ||
258 | func (z *intLogger) renderSlice(v reflect.Value) string { | ||
259 | var buf bytes.Buffer | ||
260 | |||
261 | buf.WriteRune('[') | ||
262 | |||
263 | for i := 0; i < v.Len(); i++ { | ||
264 | if i > 0 { | ||
265 | buf.WriteString(", ") | ||
266 | } | ||
267 | |||
268 | sv := v.Index(i) | ||
269 | |||
270 | var val string | ||
271 | |||
272 | switch sv.Kind() { | ||
273 | case reflect.String: | ||
274 | val = sv.String() | ||
275 | case reflect.Int, reflect.Int16, reflect.Int32, reflect.Int64: | ||
276 | val = strconv.FormatInt(sv.Int(), 10) | ||
277 | case reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64: | ||
278 | val = strconv.FormatUint(sv.Uint(), 10) | ||
279 | default: | ||
280 | val = fmt.Sprintf("%v", sv.Interface()) | ||
281 | } | ||
282 | |||
283 | if strings.ContainsAny(val, " \t\n\r") { | ||
284 | buf.WriteByte('"') | ||
285 | buf.WriteString(val) | ||
286 | buf.WriteByte('"') | ||
287 | } else { | ||
288 | buf.WriteString(val) | ||
289 | } | ||
290 | } | ||
291 | |||
292 | buf.WriteRune(']') | ||
293 | |||
294 | return buf.String() | ||
295 | } | ||
296 | |||
230 | // JSON logging function | 297 | // JSON logging function |
231 | func (z *intLogger) logJson(t time.Time, level Level, msg string, args ...interface{}) { | 298 | func (z *intLogger) logJson(t time.Time, level Level, msg string, args ...interface{}) { |
232 | vals := map[string]interface{}{ | 299 | vals := map[string]interface{}{ |
@@ -262,6 +329,8 @@ func (z *intLogger) logJson(t time.Time, level Level, msg string, args ...interf | |||
262 | } | 329 | } |
263 | } | 330 | } |
264 | 331 | ||
332 | args = append(z.implied, args...) | ||
333 | |||
265 | if args != nil && len(args) > 0 { | 334 | if args != nil && len(args) > 0 { |
266 | if len(args)%2 != 0 { | 335 | if len(args)%2 != 0 { |
267 | cs, ok := args[len(args)-1].(CapturedStacktrace) | 336 | cs, ok := args[len(args)-1].(CapturedStacktrace) |
@@ -279,7 +348,22 @@ func (z *intLogger) logJson(t time.Time, level Level, msg string, args ...interf | |||
279 | // without injecting into logs... | 348 | // without injecting into logs... |
280 | continue | 349 | continue |
281 | } | 350 | } |
282 | vals[args[i].(string)] = args[i+1] | 351 | val := args[i+1] |
352 | switch sv := val.(type) { | ||
353 | case error: | ||
354 | // Check if val is of type error. If error type doesn't | ||
355 | // implement json.Marshaler or encoding.TextMarshaler | ||
356 | // then set val to err.Error() so that it gets marshaled | ||
357 | switch sv.(type) { | ||
358 | case json.Marshaler, encoding.TextMarshaler: | ||
359 | default: | ||
360 | val = sv.Error() | ||
361 | } | ||
362 | case Format: | ||
363 | val = fmt.Sprintf(sv[0].(string), sv[1:]...) | ||
364 | } | ||
365 | |||
366 | vals[args[i].(string)] = val | ||
283 | } | 367 | } |
284 | } | 368 | } |
285 | 369 | ||
@@ -316,36 +400,66 @@ func (z *intLogger) Error(msg string, args ...interface{}) { | |||
316 | 400 | ||
317 | // Indicate that the logger would emit TRACE level logs | 401 | // Indicate that the logger would emit TRACE level logs |
318 | func (z *intLogger) IsTrace() bool { | 402 | func (z *intLogger) IsTrace() bool { |
319 | return z.level == Trace | 403 | return Level(atomic.LoadInt32(z.level)) == Trace |
320 | } | 404 | } |
321 | 405 | ||
322 | // Indicate that the logger would emit DEBUG level logs | 406 | // Indicate that the logger would emit DEBUG level logs |
323 | func (z *intLogger) IsDebug() bool { | 407 | func (z *intLogger) IsDebug() bool { |
324 | return z.level <= Debug | 408 | return Level(atomic.LoadInt32(z.level)) <= Debug |
325 | } | 409 | } |
326 | 410 | ||
327 | // Indicate that the logger would emit INFO level logs | 411 | // Indicate that the logger would emit INFO level logs |
328 | func (z *intLogger) IsInfo() bool { | 412 | func (z *intLogger) IsInfo() bool { |
329 | return z.level <= Info | 413 | return Level(atomic.LoadInt32(z.level)) <= Info |
330 | } | 414 | } |
331 | 415 | ||
332 | // Indicate that the logger would emit WARN level logs | 416 | // Indicate that the logger would emit WARN level logs |
333 | func (z *intLogger) IsWarn() bool { | 417 | func (z *intLogger) IsWarn() bool { |
334 | return z.level <= Warn | 418 | return Level(atomic.LoadInt32(z.level)) <= Warn |
335 | } | 419 | } |
336 | 420 | ||
337 | // Indicate that the logger would emit ERROR level logs | 421 | // Indicate that the logger would emit ERROR level logs |
338 | func (z *intLogger) IsError() bool { | 422 | func (z *intLogger) IsError() bool { |
339 | return z.level <= Error | 423 | return Level(atomic.LoadInt32(z.level)) <= Error |
340 | } | 424 | } |
341 | 425 | ||
342 | // Return a sub-Logger for which every emitted log message will contain | 426 | // Return a sub-Logger for which every emitted log message will contain |
343 | // the given key/value pairs. This is used to create a context specific | 427 | // the given key/value pairs. This is used to create a context specific |
344 | // Logger. | 428 | // Logger. |
345 | func (z *intLogger) With(args ...interface{}) Logger { | 429 | func (z *intLogger) With(args ...interface{}) Logger { |
430 | if len(args)%2 != 0 { | ||
431 | panic("With() call requires paired arguments") | ||
432 | } | ||
433 | |||
346 | var nz intLogger = *z | 434 | var nz intLogger = *z |
347 | 435 | ||
348 | nz.implied = append(nz.implied, args...) | 436 | result := make(map[string]interface{}, len(z.implied)+len(args)) |
437 | keys := make([]string, 0, len(z.implied)+len(args)) | ||
438 | |||
439 | // Read existing args, store map and key for consistent sorting | ||
440 | for i := 0; i < len(z.implied); i += 2 { | ||
441 | key := z.implied[i].(string) | ||
442 | keys = append(keys, key) | ||
443 | result[key] = z.implied[i+1] | ||
444 | } | ||
445 | // Read new args, store map and key for consistent sorting | ||
446 | for i := 0; i < len(args); i += 2 { | ||
447 | key := args[i].(string) | ||
448 | _, exists := result[key] | ||
449 | if !exists { | ||
450 | keys = append(keys, key) | ||
451 | } | ||
452 | result[key] = args[i+1] | ||
453 | } | ||
454 | |||
455 | // Sort keys to be consistent | ||
456 | sort.Strings(keys) | ||
457 | |||
458 | nz.implied = make([]interface{}, 0, len(z.implied)+len(args)) | ||
459 | for _, k := range keys { | ||
460 | nz.implied = append(nz.implied, k) | ||
461 | nz.implied = append(nz.implied, result[k]) | ||
462 | } | ||
349 | 463 | ||
350 | return &nz | 464 | return &nz |
351 | } | 465 | } |
@@ -357,6 +471,8 @@ func (z *intLogger) Named(name string) Logger { | |||
357 | 471 | ||
358 | if nz.name != "" { | 472 | if nz.name != "" { |
359 | nz.name = nz.name + "." + name | 473 | nz.name = nz.name + "." + name |
474 | } else { | ||
475 | nz.name = name | ||
360 | } | 476 | } |
361 | 477 | ||
362 | return &nz | 478 | return &nz |
@@ -373,6 +489,12 @@ func (z *intLogger) ResetNamed(name string) Logger { | |||
373 | return &nz | 489 | return &nz |
374 | } | 490 | } |
375 | 491 | ||
492 | // Update the logging level on-the-fly. This will affect all subloggers as | ||
493 | // well. | ||
494 | func (z *intLogger) SetLevel(level Level) { | ||
495 | atomic.StoreInt32(z.level, int32(level)) | ||
496 | } | ||
497 | |||
376 | // Create a *log.Logger that will send it's data through this Logger. This | 498 | // Create a *log.Logger that will send it's data through this Logger. This |
377 | // allows packages that expect to be using the standard library log to actually | 499 | // allows packages that expect to be using the standard library log to actually |
378 | // use this logger. | 500 | // use this logger. |
diff --git a/vendor/github.com/hashicorp/go-hclog/log.go b/vendor/github.com/hashicorp/go-hclog/log.go index 6bb16ba..d98714e 100644 --- a/vendor/github.com/hashicorp/go-hclog/log.go +++ b/vendor/github.com/hashicorp/go-hclog/log.go | |||
@@ -5,6 +5,7 @@ import ( | |||
5 | "log" | 5 | "log" |
6 | "os" | 6 | "os" |
7 | "strings" | 7 | "strings" |
8 | "sync" | ||
8 | ) | 9 | ) |
9 | 10 | ||
10 | var ( | 11 | var ( |
@@ -12,7 +13,7 @@ var ( | |||
12 | DefaultLevel = Info | 13 | DefaultLevel = Info |
13 | ) | 14 | ) |
14 | 15 | ||
15 | type Level int | 16 | type Level int32 |
16 | 17 | ||
17 | const ( | 18 | const ( |
18 | // This is a special level used to indicate that no level has been | 19 | // This is a special level used to indicate that no level has been |
@@ -36,6 +37,18 @@ const ( | |||
36 | Error Level = 5 | 37 | Error Level = 5 |
37 | ) | 38 | ) |
38 | 39 | ||
40 | // When processing a value of this type, the logger automatically treats the first | ||
41 | // argument as a Printf formatting string and passes the rest as the values to be | ||
42 | // formatted. For example: L.Info(Fmt{"%d beans/day", beans}). This is a simple | ||
43 | // convience type for when formatting is required. | ||
44 | type Format []interface{} | ||
45 | |||
46 | // Fmt returns a Format type. This is a convience function for creating a Format | ||
47 | // type. | ||
48 | func Fmt(str string, args ...interface{}) Format { | ||
49 | return append(Format{str}, args...) | ||
50 | } | ||
51 | |||
39 | // LevelFromString returns a Level type for the named log level, or "NoLevel" if | 52 | // LevelFromString returns a Level type for the named log level, or "NoLevel" if |
40 | // the level string is invalid. This facilitates setting the log level via | 53 | // the level string is invalid. This facilitates setting the log level via |
41 | // config or environment variable by name in a predictable way. | 54 | // config or environment variable by name in a predictable way. |
@@ -108,6 +121,10 @@ type Logger interface { | |||
108 | // the current name as well. | 121 | // the current name as well. |
109 | ResetNamed(name string) Logger | 122 | ResetNamed(name string) Logger |
110 | 123 | ||
124 | // Updates the level. This should affect all sub-loggers as well. If an | ||
125 | // implementation cannot update the level on the fly, it should no-op. | ||
126 | SetLevel(level Level) | ||
127 | |||
111 | // Return a value that conforms to the stdlib log.Logger interface | 128 | // Return a value that conforms to the stdlib log.Logger interface |
112 | StandardLogger(opts *StandardLoggerOptions) *log.Logger | 129 | StandardLogger(opts *StandardLoggerOptions) *log.Logger |
113 | } | 130 | } |
@@ -127,12 +144,18 @@ type LoggerOptions struct { | |||
127 | // The threshold for the logger. Anything less severe is supressed | 144 | // The threshold for the logger. Anything less severe is supressed |
128 | Level Level | 145 | Level Level |
129 | 146 | ||
130 | // Where to write the logs to. Defaults to os.Stdout if nil | 147 | // Where to write the logs to. Defaults to os.Stderr if nil |
131 | Output io.Writer | 148 | Output io.Writer |
132 | 149 | ||
150 | // An optional mutex pointer in case Output is shared | ||
151 | Mutex *sync.Mutex | ||
152 | |||
133 | // Control if the output should be in JSON. | 153 | // Control if the output should be in JSON. |
134 | JSONFormat bool | 154 | JSONFormat bool |
135 | 155 | ||
136 | // Intclude file and line information in each log line | 156 | // Include file and line information in each log line |
137 | IncludeLocation bool | 157 | IncludeLocation bool |
158 | |||
159 | // The time format to use instead of the default | ||
160 | TimeFormat string | ||
138 | } | 161 | } |
diff --git a/vendor/github.com/hashicorp/go-hclog/nulllogger.go b/vendor/github.com/hashicorp/go-hclog/nulllogger.go new file mode 100644 index 0000000..0942361 --- /dev/null +++ b/vendor/github.com/hashicorp/go-hclog/nulllogger.go | |||
@@ -0,0 +1,47 @@ | |||
1 | package hclog | ||
2 | |||
3 | import ( | ||
4 | "io/ioutil" | ||
5 | "log" | ||
6 | ) | ||
7 | |||
8 | // NewNullLogger instantiates a Logger for which all calls | ||
9 | // will succeed without doing anything. | ||
10 | // Useful for testing purposes. | ||
11 | func NewNullLogger() Logger { | ||
12 | return &nullLogger{} | ||
13 | } | ||
14 | |||
15 | type nullLogger struct{} | ||
16 | |||
17 | func (l *nullLogger) Trace(msg string, args ...interface{}) {} | ||
18 | |||
19 | func (l *nullLogger) Debug(msg string, args ...interface{}) {} | ||
20 | |||
21 | func (l *nullLogger) Info(msg string, args ...interface{}) {} | ||
22 | |||
23 | func (l *nullLogger) Warn(msg string, args ...interface{}) {} | ||
24 | |||
25 | func (l *nullLogger) Error(msg string, args ...interface{}) {} | ||
26 | |||
27 | func (l *nullLogger) IsTrace() bool { return false } | ||
28 | |||
29 | func (l *nullLogger) IsDebug() bool { return false } | ||
30 | |||
31 | func (l *nullLogger) IsInfo() bool { return false } | ||
32 | |||
33 | func (l *nullLogger) IsWarn() bool { return false } | ||
34 | |||
35 | func (l *nullLogger) IsError() bool { return false } | ||
36 | |||
37 | func (l *nullLogger) With(args ...interface{}) Logger { return l } | ||
38 | |||
39 | func (l *nullLogger) Named(name string) Logger { return l } | ||
40 | |||
41 | func (l *nullLogger) ResetNamed(name string) Logger { return l } | ||
42 | |||
43 | func (l *nullLogger) SetLevel(level Level) {} | ||
44 | |||
45 | func (l *nullLogger) StandardLogger(opts *StandardLoggerOptions) *log.Logger { | ||
46 | return log.New(ioutil.Discard, "", log.LstdFlags) | ||
47 | } | ||