OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package logging | 5 package logging |
6 | 6 |
7 import ( | 7 import ( |
8 "golang.org/x/net/context" | 8 "golang.org/x/net/context" |
9 ) | 9 ) |
10 | 10 |
11 // SetFilter sets the context's logging filter value. | |
12 func SetFilter(c context.Context, filter string) context.Context { | |
13 return SetField(c, FilterOnKey, filter) | |
14 } | |
15 | |
16 // SetError returns a context with its error field set. | 11 // SetError returns a context with its error field set. |
17 func SetError(c context.Context, err error) context.Context { | 12 func SetError(c context.Context, err error) context.Context { |
18 return SetField(c, ErrorKey, err) | 13 return SetField(c, ErrorKey, err) |
19 } | 14 } |
20 | 15 |
21 // IsLogging tests whether the currently-configured logger is logging at the | 16 // IsLogging tests whether the currently-configured logger is logging at the |
22 // specified level. | 17 // specified level. |
23 func IsLogging(c context.Context, l Level) bool { | 18 func IsLogging(c context.Context, l Level) bool { |
24 return l >= GetLevel(c) | 19 return l >= GetLevel(c) |
25 } | 20 } |
(...skipping 10 matching lines...) Expand all Loading... |
36 | 31 |
37 // Warningf is a shorthand method to call the current logger's Errorf method. | 32 // Warningf is a shorthand method to call the current logger's Errorf method. |
38 func Warningf(c context.Context, fmt string, args ...interface{}) { | 33 func Warningf(c context.Context, fmt string, args ...interface{}) { |
39 Get(c).LogCall(Warning, 1, fmt, args) | 34 Get(c).LogCall(Warning, 1, fmt, args) |
40 } | 35 } |
41 | 36 |
42 // Errorf is a shorthand method to call the current logger's Errorf method. | 37 // Errorf is a shorthand method to call the current logger's Errorf method. |
43 func Errorf(c context.Context, fmt string, args ...interface{}) { | 38 func Errorf(c context.Context, fmt string, args ...interface{}) { |
44 Get(c).LogCall(Error, 1, fmt, args) | 39 Get(c).LogCall(Error, 1, fmt, args) |
45 } | 40 } |
OLD | NEW |