zlog/context.go

434 lines
14 KiB
Go
Raw Normal View History

2017-05-12 05:24:39 +00:00
package zerolog
import (
"fmt"
"io/ioutil"
"math"
"net"
"time"
)
2017-05-12 05:24:39 +00:00
// Context configures a new sub-logger with contextual fields.
type Context struct {
l Logger
}
// Logger returns the logger with the context previously set.
func (c Context) Logger() Logger {
return c.l
}
// Fields is a helper function to use a map or slice to set fields using type assertion.
// Only map[string]interface{} and []interface{} are accepted. []interface{} must
// alternate string keys and arbitrary values, and extraneous ones are ignored.
func (c Context) Fields(fields interface{}) Context {
c.l.context = appendFields(c.l.context, fields)
return c
}
2017-05-18 07:10:45 +00:00
// Dict adds the field key with the dict to the logger context.
func (c Context) Dict(key string, dict *Event) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
dict.buf = enc.AppendEndMarker(dict.buf)
c.l.context = append(enc.AppendKey(c.l.context, key), dict.buf...)
putEvent(dict)
return c
2017-05-18 07:10:45 +00:00
}
2017-07-26 07:14:43 +00:00
// Array adds the field key with an array to the event context.
// Use zerolog.Arr() to create the array or pass a type that
// implement the LogArrayMarshaler interface.
func (c Context) Array(key string, arr LogArrayMarshaler) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendKey(c.l.context, key)
2017-07-26 07:14:43 +00:00
if arr, ok := arr.(*Array); ok {
c.l.context = arr.write(c.l.context)
return c
}
var a *Array
if aa, ok := arr.(*Array); ok {
a = aa
} else {
a = Arr()
arr.MarshalZerologArray(a)
}
c.l.context = a.write(c.l.context)
return c
}
// Object marshals an object that implement the LogObjectMarshaler interface.
func (c Context) Object(key string, obj LogObjectMarshaler) Context {
e := newEvent(levelWriterAdapter{ioutil.Discard}, 0)
e.Object(key, obj)
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendObjectData(c.l.context, e.buf)
putEvent(e)
return c
}
// EmbedObject marshals and Embeds an object that implement the LogObjectMarshaler interface.
func (c Context) EmbedObject(obj LogObjectMarshaler) Context {
e := newEvent(levelWriterAdapter{ioutil.Discard}, 0)
e.EmbedObject(obj)
c.l.context = enc.AppendObjectData(c.l.context, e.buf)
putEvent(e)
return c
}
2017-05-17 04:52:22 +00:00
// Str adds the field key with val as a string to the logger context.
2017-05-12 05:24:39 +00:00
func (c Context) Str(key, val string) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendString(enc.AppendKey(c.l.context, key), val)
return c
2017-05-12 05:24:39 +00:00
}
2017-07-25 19:50:35 +00:00
// Strs adds the field key with val as a string to the logger context.
func (c Context) Strs(key string, vals []string) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendStrings(enc.AppendKey(c.l.context, key), vals)
2017-07-25 19:50:35 +00:00
return c
}
// Stringer adds the field key with val.String() (or null if val is nil) to the logger context.
func (c Context) Stringer(key string, val fmt.Stringer) Context {
if val != nil {
c.l.context = enc.AppendString(enc.AppendKey(c.l.context, key), val.String())
return c
}
c.l.context = enc.AppendInterface(enc.AppendKey(c.l.context, key), nil)
return c
}
// Bytes adds the field key with val as a []byte to the logger context.
func (c Context) Bytes(key string, val []byte) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendBytes(enc.AppendKey(c.l.context, key), val)
return c
}
// Hex adds the field key with val as a hex string to the logger context.
func (c Context) Hex(key string, val []byte) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendHex(enc.AppendKey(c.l.context, key), val)
return c
}
2018-02-13 00:05:27 +00:00
// RawJSON adds already encoded JSON to context.
//
// No sanity check is performed on b; it must not contain carriage returns and
// be valid JSON.
func (c Context) RawJSON(key string, b []byte) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = appendJSON(enc.AppendKey(c.l.context, key), b)
2018-02-13 00:05:27 +00:00
return c
}
// AnErr adds the field key with serialized err to the logger context.
2017-06-02 07:56:14 +00:00
func (c Context) AnErr(key string, err error) Context {
switch m := ErrorMarshalFunc(err).(type) {
case nil:
return c
case LogObjectMarshaler:
return c.Object(key, m)
case error:
if m == nil || isNilValue(m) {
return c
} else {
return c.Str(key, m.Error())
}
case string:
return c.Str(key, m)
default:
return c.Interface(key, m)
2017-07-26 03:51:49 +00:00
}
2017-06-02 07:56:14 +00:00
}
// Errs adds the field key with errs as an array of serialized errors to the
// logger context.
2017-07-25 19:50:35 +00:00
func (c Context) Errs(key string, errs []error) Context {
arr := Arr()
for _, err := range errs {
switch m := ErrorMarshalFunc(err).(type) {
case LogObjectMarshaler:
arr = arr.Object(m)
case error:
if m == nil || isNilValue(m) {
arr = arr.Interface(nil)
} else {
arr = arr.Str(m.Error())
}
case string:
arr = arr.Str(m)
default:
arr = arr.Interface(m)
}
}
return c.Array(key, arr)
2017-07-25 19:50:35 +00:00
}
// Err adds the field "error" with serialized err to the logger context.
2017-05-12 05:24:39 +00:00
func (c Context) Err(err error) Context {
return c.AnErr(ErrorFieldName, err)
2017-05-12 05:24:39 +00:00
}
2017-07-25 19:50:35 +00:00
// Bool adds the field key with val as a bool to the logger context.
2017-05-12 05:24:39 +00:00
func (c Context) Bool(key string, b bool) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendBool(enc.AppendKey(c.l.context, key), b)
return c
2017-05-12 05:24:39 +00:00
}
2017-07-25 19:50:35 +00:00
// Bools adds the field key with val as a []bool to the logger context.
func (c Context) Bools(key string, b []bool) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendBools(enc.AppendKey(c.l.context, key), b)
2017-07-25 19:50:35 +00:00
return c
}
2017-05-17 04:52:22 +00:00
// Int adds the field key with i as a int to the logger context.
2017-05-12 05:24:39 +00:00
func (c Context) Int(key string, i int) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendInt(enc.AppendKey(c.l.context, key), i)
return c
2017-05-12 05:24:39 +00:00
}
2017-07-25 19:50:35 +00:00
// Ints adds the field key with i as a []int to the logger context.
func (c Context) Ints(key string, i []int) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendInts(enc.AppendKey(c.l.context, key), i)
2017-07-25 19:50:35 +00:00
return c
}
2017-05-17 04:52:22 +00:00
// Int8 adds the field key with i as a int8 to the logger context.
2017-05-12 05:24:39 +00:00
func (c Context) Int8(key string, i int8) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendInt8(enc.AppendKey(c.l.context, key), i)
return c
2017-05-12 05:24:39 +00:00
}
2017-07-25 19:50:35 +00:00
// Ints8 adds the field key with i as a []int8 to the logger context.
func (c Context) Ints8(key string, i []int8) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendInts8(enc.AppendKey(c.l.context, key), i)
2017-07-25 19:50:35 +00:00
return c
}
2017-05-17 04:52:22 +00:00
// Int16 adds the field key with i as a int16 to the logger context.
2017-05-12 05:24:39 +00:00
func (c Context) Int16(key string, i int16) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendInt16(enc.AppendKey(c.l.context, key), i)
return c
2017-05-12 05:24:39 +00:00
}
2017-07-25 19:50:35 +00:00
// Ints16 adds the field key with i as a []int16 to the logger context.
func (c Context) Ints16(key string, i []int16) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendInts16(enc.AppendKey(c.l.context, key), i)
2017-07-25 19:50:35 +00:00
return c
}
2017-05-17 04:52:22 +00:00
// Int32 adds the field key with i as a int32 to the logger context.
2017-05-12 05:24:39 +00:00
func (c Context) Int32(key string, i int32) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendInt32(enc.AppendKey(c.l.context, key), i)
return c
2017-05-12 05:24:39 +00:00
}
2017-07-25 19:50:35 +00:00
// Ints32 adds the field key with i as a []int32 to the logger context.
func (c Context) Ints32(key string, i []int32) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendInts32(enc.AppendKey(c.l.context, key), i)
2017-07-25 19:50:35 +00:00
return c
}
2017-05-17 04:52:22 +00:00
// Int64 adds the field key with i as a int64 to the logger context.
2017-05-12 05:24:39 +00:00
func (c Context) Int64(key string, i int64) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendInt64(enc.AppendKey(c.l.context, key), i)
return c
2017-05-12 05:24:39 +00:00
}
2017-07-25 19:50:35 +00:00
// Ints64 adds the field key with i as a []int64 to the logger context.
func (c Context) Ints64(key string, i []int64) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendInts64(enc.AppendKey(c.l.context, key), i)
2017-07-25 19:50:35 +00:00
return c
}
2017-05-17 04:52:22 +00:00
// Uint adds the field key with i as a uint to the logger context.
2017-05-12 05:24:39 +00:00
func (c Context) Uint(key string, i uint) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendUint(enc.AppendKey(c.l.context, key), i)
return c
2017-05-12 05:24:39 +00:00
}
2017-07-25 19:50:35 +00:00
// Uints adds the field key with i as a []uint to the logger context.
func (c Context) Uints(key string, i []uint) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendUints(enc.AppendKey(c.l.context, key), i)
2017-07-25 19:50:35 +00:00
return c
}
2017-05-17 04:52:22 +00:00
// Uint8 adds the field key with i as a uint8 to the logger context.
2017-05-12 05:24:39 +00:00
func (c Context) Uint8(key string, i uint8) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendUint8(enc.AppendKey(c.l.context, key), i)
return c
2017-05-12 05:24:39 +00:00
}
2017-07-25 19:50:35 +00:00
// Uints8 adds the field key with i as a []uint8 to the logger context.
func (c Context) Uints8(key string, i []uint8) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendUints8(enc.AppendKey(c.l.context, key), i)
2017-07-25 19:50:35 +00:00
return c
}
2017-05-17 04:52:22 +00:00
// Uint16 adds the field key with i as a uint16 to the logger context.
2017-05-12 05:24:39 +00:00
func (c Context) Uint16(key string, i uint16) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendUint16(enc.AppendKey(c.l.context, key), i)
return c
2017-05-12 05:24:39 +00:00
}
2017-07-25 19:50:35 +00:00
// Uints16 adds the field key with i as a []uint16 to the logger context.
func (c Context) Uints16(key string, i []uint16) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendUints16(enc.AppendKey(c.l.context, key), i)
2017-07-25 19:50:35 +00:00
return c
}
2017-05-17 04:52:22 +00:00
// Uint32 adds the field key with i as a uint32 to the logger context.
2017-05-12 05:24:39 +00:00
func (c Context) Uint32(key string, i uint32) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendUint32(enc.AppendKey(c.l.context, key), i)
return c
2017-05-12 05:24:39 +00:00
}
2017-07-25 19:50:35 +00:00
// Uints32 adds the field key with i as a []uint32 to the logger context.
func (c Context) Uints32(key string, i []uint32) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendUints32(enc.AppendKey(c.l.context, key), i)
2017-07-25 19:50:35 +00:00
return c
}
2017-05-17 04:52:22 +00:00
// Uint64 adds the field key with i as a uint64 to the logger context.
2017-05-12 05:24:39 +00:00
func (c Context) Uint64(key string, i uint64) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendUint64(enc.AppendKey(c.l.context, key), i)
return c
2017-05-12 05:24:39 +00:00
}
2017-07-25 19:50:35 +00:00
// Uints64 adds the field key with i as a []uint64 to the logger context.
func (c Context) Uints64(key string, i []uint64) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendUints64(enc.AppendKey(c.l.context, key), i)
2017-07-25 19:50:35 +00:00
return c
}
2017-05-17 04:52:22 +00:00
// Float32 adds the field key with f as a float32 to the logger context.
2017-05-12 05:24:39 +00:00
func (c Context) Float32(key string, f float32) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendFloat32(enc.AppendKey(c.l.context, key), f)
return c
2017-05-12 05:24:39 +00:00
}
2017-07-25 19:50:35 +00:00
// Floats32 adds the field key with f as a []float32 to the logger context.
func (c Context) Floats32(key string, f []float32) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendFloats32(enc.AppendKey(c.l.context, key), f)
2017-07-25 19:50:35 +00:00
return c
}
2017-05-17 04:52:22 +00:00
// Float64 adds the field key with f as a float64 to the logger context.
2017-05-12 05:24:39 +00:00
func (c Context) Float64(key string, f float64) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendFloat64(enc.AppendKey(c.l.context, key), f)
return c
2017-05-12 05:24:39 +00:00
}
2017-07-25 19:50:35 +00:00
// Floats64 adds the field key with f as a []float64 to the logger context.
func (c Context) Floats64(key string, f []float64) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendFloats64(enc.AppendKey(c.l.context, key), f)
2017-07-25 19:50:35 +00:00
return c
}
type timestampHook struct{}
func (ts timestampHook) Run(e *Event, level Level, msg string) {
e.Timestamp()
}
var th = timestampHook{}
2017-05-17 04:52:22 +00:00
// Timestamp adds the current local time as UNIX timestamp to the logger context with the "time" key.
// To customize the key name, change zerolog.TimestampFieldName.
//
// NOTE: It won't dedupe the "time" key if the *Context has one already.
2017-05-12 05:24:39 +00:00
func (c Context) Timestamp() Context {
c.l = c.l.Hook(th)
return c
2017-05-12 05:24:39 +00:00
}
2017-05-17 04:52:22 +00:00
// Time adds the field key with t formated as string using zerolog.TimeFieldFormat.
2017-05-12 05:24:39 +00:00
func (c Context) Time(key string, t time.Time) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendTime(enc.AppendKey(c.l.context, key), t, TimeFieldFormat)
return c
2017-05-12 05:24:39 +00:00
}
2017-07-25 19:50:35 +00:00
// Times adds the field key with t formated as string using zerolog.TimeFieldFormat.
func (c Context) Times(key string, t []time.Time) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendTimes(enc.AppendKey(c.l.context, key), t, TimeFieldFormat)
2017-07-25 19:50:35 +00:00
return c
}
2017-05-20 05:43:10 +00:00
// Dur adds the fields key with d divided by unit and stored as a float.
2017-05-21 04:08:42 +00:00
func (c Context) Dur(key string, d time.Duration) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendDuration(enc.AppendKey(c.l.context, key), d, DurationFieldUnit, DurationFieldInteger)
2017-05-20 05:43:10 +00:00
return c
}
2017-07-25 19:50:35 +00:00
// Durs adds the fields key with d divided by unit and stored as a float.
func (c Context) Durs(key string, d []time.Duration) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendDurations(enc.AppendKey(c.l.context, key), d, DurationFieldUnit, DurationFieldInteger)
2017-07-25 19:50:35 +00:00
return c
}
2017-05-20 05:25:37 +00:00
// Interface adds the field key with obj marshaled using reflection.
func (c Context) Interface(key string, i interface{}) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendInterface(enc.AppendKey(c.l.context, key), i)
return c
}
type callerHook struct {
callerSkipFrameCount int
}
func newCallerHook(skipFrameCount int) callerHook {
return callerHook{callerSkipFrameCount: skipFrameCount}
}
func (ch callerHook) Run(e *Event, level Level, msg string) {
switch ch.callerSkipFrameCount {
case useGlobalSkipFrameCount:
// Extra frames to skip (added by hook infra).
e.caller(CallerSkipFrameCount + contextCallerSkipFrameCount)
default:
// Extra frames to skip (added by hook infra).
e.caller(ch.callerSkipFrameCount + contextCallerSkipFrameCount)
}
}
// useGlobalSkipFrameCount acts as a flag to informat callerHook.Run
// to use the global CallerSkipFrameCount.
const useGlobalSkipFrameCount = math.MinInt32
// ch is the default caller hook using the global CallerSkipFrameCount.
var ch = newCallerHook(useGlobalSkipFrameCount)
// Caller adds the file:line of the caller with the zerolog.CallerFieldName key.
func (c Context) Caller() Context {
c.l = c.l.Hook(ch)
return c
}
// CallerWithSkipFrameCount adds the file:line of the caller with the zerolog.CallerFieldName key.
// The specified skipFrameCount int will override the global CallerSkipFrameCount for this context's respective logger.
// If set to -1 the global CallerSkipFrameCount will be used.
func (c Context) CallerWithSkipFrameCount(skipFrameCount int) Context {
c.l = c.l.Hook(newCallerHook(skipFrameCount))
return c
}
// Stack enables stack trace printing for the error passed to Err().
func (c Context) Stack() Context {
2021-03-23 22:01:01 +00:00
c.l.stack = true
return c
}
// IPAddr adds IPv4 or IPv6 Address to the context
func (c Context) IPAddr(key string, ip net.IP) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendIPAddr(enc.AppendKey(c.l.context, key), ip)
return c
}
// IPPrefix adds IPv4 or IPv6 Prefix (address and mask) to the context
func (c Context) IPPrefix(key string, pfx net.IPNet) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendIPPrefix(enc.AppendKey(c.l.context, key), pfx)
return c
}
// MACAddr adds MAC address to the context
func (c Context) MACAddr(key string, ha net.HardwareAddr) Context {
Get back some ns by removing the extra inferance added by binary support benchstat old new name old time/op new time/op delta LogEmpty-8 15.2ns ±14% 13.4ns ± 3% -12.11% (p=0.008 n=5+5) Disabled-8 2.50ns ± 1% 2.28ns ± 6% -8.81% (p=0.008 n=5+5) Info-8 44.4ns ± 1% 36.4ns ± 4% -17.99% (p=0.008 n=5+5) ContextFields-8 47.6ns ± 1% 39.4ns ± 7% -17.30% (p=0.008 n=5+5) ContextAppend-8 18.9ns ± 4% 15.2ns ± 4% -19.68% (p=0.008 n=5+5) LogFields-8 181ns ± 2% 173ns ± 2% -4.63% (p=0.008 n=5+5) LogArrayObject-8 530ns ± 3% 487ns ± 3% -8.11% (p=0.008 n=5+5) LogFieldType/Int-8 29.5ns ± 3% 28.8ns ± 2% ~ (p=0.167 n=5+5) LogFieldType/Interface-8 180ns ± 7% 175ns ± 4% ~ (p=0.579 n=5+5) LogFieldType/Interface(Object)-8 87.8ns ± 3% 80.5ns ± 1% -8.29% (p=0.008 n=5+5) LogFieldType/Object-8 83.7ns ± 2% 77.2ns ± 3% -7.76% (p=0.008 n=5+5) LogFieldType/Bools-8 34.6ns ± 3% 32.3ns ± 6% -6.64% (p=0.032 n=5+5) LogFieldType/Float-8 43.0ns ± 4% 40.5ns ± 4% -5.86% (p=0.016 n=5+5) LogFieldType/Str-8 29.8ns ± 2% 26.5ns ± 5% -11.01% (p=0.008 n=5+5) LogFieldType/Err-8 32.8ns ± 2% 29.8ns ± 4% -9.21% (p=0.008 n=5+5) LogFieldType/Durs-8 309ns ± 3% 304ns ± 3% ~ (p=0.238 n=5+5) LogFieldType/Floats-8 175ns ± 2% 174ns ± 3% ~ (p=0.968 n=5+5) LogFieldType/Strs-8 51.0ns ± 3% 48.4ns ± 6% -5.06% (p=0.032 n=5+5) LogFieldType/Dur-8 44.5ns ± 3% 41.3ns ± 3% -7.11% (p=0.008 n=5+5) LogFieldType/Interface(Objects)-8 758ns ± 3% 760ns ± 6% ~ (p=1.000 n=5+5) LogFieldType/Interfaces-8 772ns ± 5% 762ns ± 4% ~ (p=0.794 n=5+5) LogFieldType/Bool-8 28.0ns ± 6% 26.5ns ± 9% ~ (p=0.143 n=5+5) LogFieldType/Ints-8 49.6ns ± 2% 46.2ns ± 2% -6.70% (p=0.008 n=5+5) LogFieldType/Errs-8 46.5ns ±11% 40.9ns ± 4% -11.92% (p=0.008 n=5+5) LogFieldType/Time-8 115ns ± 3% 113ns ± 3% ~ (p=0.167 n=5+5) LogFieldType/Times-8 810ns ± 1% 811ns ± 3% ~ (p=0.889 n=5+5) ContextFieldType/Errs-8 158ns ± 6% 156ns ±12% ~ (p=1.000 n=5+5) ContextFieldType/Times-8 165ns ±11% 173ns ± 9% ~ (p=0.651 n=5+5) ContextFieldType/Interface-8 289ns ±13% 287ns ±11% ~ (p=0.690 n=5+5) ContextFieldType/Interface(Object)-8 285ns ±12% 297ns ± 6% ~ (p=0.238 n=5+5) ContextFieldType/Interface(Objects)-8 941ns ± 6% 941ns ± 5% ~ (p=1.000 n=5+5) ContextFieldType/Object-8 201ns ± 5% 210ns ±12% ~ (p=0.262 n=5+5) ContextFieldType/Ints-8 173ns ±10% 165ns ± 9% ~ (p=0.198 n=5+5) ContextFieldType/Floats-8 297ns ± 6% 292ns ± 7% ~ (p=0.579 n=5+5) ContextFieldType/Timestamp-8 174ns ± 9% 174ns ±11% ~ (p=0.810 n=5+5) ContextFieldType/Durs-8 445ns ± 9% 425ns ± 3% ~ (p=0.151 n=5+5) ContextFieldType/Interfaces-8 944ns ± 6% 876ns ±10% ~ (p=0.095 n=5+5) ContextFieldType/Strs-8 179ns ±11% 165ns ±13% ~ (p=0.135 n=5+5) ContextFieldType/Dur-8 158ns ± 8% 160ns ±19% ~ (p=1.000 n=5+5) ContextFieldType/Time-8 152ns ±15% 148ns ±14% ~ (p=0.952 n=5+5) ContextFieldType/Str-8 146ns ±12% 147ns ±16% ~ (p=0.841 n=5+5) ContextFieldType/Err-8 138ns ±12% 145ns ±17% ~ (p=0.595 n=5+5) ContextFieldType/Int-8 145ns ±10% 146ns ±13% ~ (p=0.873 n=5+5) ContextFieldType/Float-8 181ns ± 9% 162ns ±12% ~ (p=0.151 n=5+5) ContextFieldType/Bool-8 153ns ±10% 131ns ±19% ~ (p=0.063 n=5+5) ContextFieldType/Bools-8 149ns ±11% 160ns ±16% ~ (p=0.500 n=5+5)
2018-05-10 22:01:41 +00:00
c.l.context = enc.AppendMACAddr(enc.AppendKey(c.l.context, key), ha)
return c
}