@@ -43,7 +43,9 @@ limitations under the License.
43
43
//
44
44
// Info() and Error() are very similar, but they are separate methods so that
45
45
// LogSink implementations can choose to do things like attach additional
46
- // information (such as stack traces) on calls to Error().
46
+ // information (such as stack traces) on calls to Error(). Error() messages are
47
+ // always logged, regardless of the current verbosity. If there is no error
48
+ // instance available, passing nil is valid.
47
49
//
48
50
// Verbosity
49
51
//
@@ -53,6 +55,7 @@ limitations under the License.
53
55
// Log-lines with V-levels that are not enabled (as per the LogSink) will not
54
56
// be written. Level V(0) is the default, and logger.V(0).Info() has the same
55
57
// meaning as logger.Info(). Negative V-levels have the same meaning as V(0).
58
+ // Error messages do not have a verbosity level and are always logged.
56
59
//
57
60
// Where we might have written:
58
61
// if flVerbose >= 2 {
@@ -253,11 +256,13 @@ func (l Logger) Info(msg string, keysAndValues ...interface{}) {
253
256
// Error logs an error, with the given message and key/value pairs as context.
254
257
// It functions similarly to Info, but may have unique behavior, and should be
255
258
// preferred for logging errors (see the package documentations for more
256
- // information).
259
+ // information). The log message will always be emitted, regardless of
260
+ // verbosity level.
257
261
//
258
262
// The msg argument should be used to add context to any underlying error,
259
263
// while the err argument should be used to attach the actual error that
260
- // triggered this log line, if present.
264
+ // triggered this log line, if present. The err parameter is optional
265
+ // and nil may be passed instead of an error instance.
261
266
func (l Logger ) Error (err error , msg string , keysAndValues ... interface {}) {
262
267
if withHelper , ok := l .sink .(CallStackHelperLogSink ); ok {
263
268
withHelper .GetCallStackHelper ()()
0 commit comments