Skip to content

Commit

Permalink
Merge 3f791df into b56bc62
Browse files Browse the repository at this point in the history
  • Loading branch information
akshayjshah committed Aug 2, 2016
2 parents b56bc62 + 3f791df commit 92d6775
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
4 changes: 2 additions & 2 deletions benchmarks/logrus_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func BenchmarkZapBarkifyAddingFields(b *testing.B) {
logger := zbark.Barkify(zap.New(
zap.NewJSONEncoder(),
zap.DebugLevel,
zap.Output(zap.Discard),
zap.DiscardOutput,
))
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
Expand Down Expand Up @@ -113,7 +113,7 @@ func BenchmarkZapBarkifyWithAccumulatedContext(b *testing.B) {
baseLogger := zbark.Barkify(zap.New(
zap.NewJSONEncoder(),
zap.DebugLevel,
zap.Output(zap.Discard),
zap.DiscardOutput,
))
logger := baseLogger.WithFields(bark.Fields{
"int": 1,
Expand Down
10 changes: 6 additions & 4 deletions benchmarks/stdlib_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ func BenchmarkStandardLibraryWithoutFields(b *testing.B) {
}

func BenchmarkZapStandardizeWithoutFields(b *testing.B) {
logger, err := zwrap.Standardize(zap.New(
zap.NewJSONEncoder(),
zap.DebugLevel,
zap.Output(zap.Discard)),
logger, err := zwrap.Standardize(
zap.New(
zap.NewJSONEncoder(),
zap.DebugLevel,
zap.DiscardOutput,
),
zap.InfoLevel,
)
if err != nil {
Expand Down
22 changes: 11 additions & 11 deletions benchmarks/zap_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func fakeMessages(n int) []string {
}

func BenchmarkZapDisabledLevelsWithoutFields(b *testing.B) {
logger := zap.New(zap.NewJSONEncoder(), zap.ErrorLevel, zap.Output(zap.Discard))
logger := zap.New(zap.NewJSONEncoder(), zap.ErrorLevel, zap.DiscardOutput)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
Expand All @@ -89,7 +89,7 @@ func BenchmarkZapDisabledLevelsAccumulatedContext(b *testing.B) {
logger := zap.New(
zap.NewJSONEncoder(),
zap.ErrorLevel,
zap.Output(zap.Discard),
zap.DiscardOutput,
zap.Fields(context...),
)
b.ResetTimer()
Expand All @@ -104,7 +104,7 @@ func BenchmarkZapDisabledLevelsAddingFields(b *testing.B) {
logger := zap.New(
zap.NewJSONEncoder(),
zap.ErrorLevel,
zap.Output(zap.Discard),
zap.DiscardOutput,
)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
Expand All @@ -118,7 +118,7 @@ func BenchmarkZapDisabledLevelsCheckAddingFields(b *testing.B) {
logger := zap.New(
zap.NewJSONEncoder(),
zap.ErrorLevel,
zap.Output(zap.Discard),
zap.DiscardOutput,
)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
Expand All @@ -134,7 +134,7 @@ func BenchmarkZapAddingFields(b *testing.B) {
logger := zap.New(
zap.NewJSONEncoder(),
zap.DebugLevel,
zap.Output(zap.Discard),
zap.DiscardOutput,
)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
Expand All @@ -149,7 +149,7 @@ func BenchmarkZapWithAccumulatedContext(b *testing.B) {
logger := zap.New(
zap.NewJSONEncoder(),
zap.DebugLevel,
zap.Output(zap.Discard),
zap.DiscardOutput,
zap.Fields(context...),
)
b.ResetTimer()
Expand All @@ -164,7 +164,7 @@ func BenchmarkZapWithoutFields(b *testing.B) {
logger := zap.New(
zap.NewJSONEncoder(),
zap.DebugLevel,
zap.Output(zap.Discard),
zap.DiscardOutput,
)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
Expand All @@ -179,7 +179,7 @@ func BenchmarkZapSampleWithoutFields(b *testing.B) {
base := zap.New(
zap.NewJSONEncoder(),
zap.DebugLevel,
zap.Output(zap.Discard),
zap.DiscardOutput,
)
logger := zwrap.Sample(base, time.Second, 10, 10000)
b.ResetTimer()
Expand All @@ -197,7 +197,7 @@ func BenchmarkZapSampleAddingFields(b *testing.B) {
base := zap.New(
zap.NewJSONEncoder(),
zap.DebugLevel,
zap.Output(zap.Discard),
zap.DiscardOutput,
)
logger := zwrap.Sample(base, time.Second, 10, 10000)
b.ResetTimer()
Expand All @@ -215,7 +215,7 @@ func BenchmarkZapSampleCheckWithoutFields(b *testing.B) {
base := zap.New(
zap.NewJSONEncoder(),
zap.DebugLevel,
zap.Output(zap.Discard),
zap.DiscardOutput,
)
logger := zwrap.Sample(base, time.Second, 10, 10000)
b.ResetTimer()
Expand All @@ -235,7 +235,7 @@ func BenchmarkZapSampleCheckAddingFields(b *testing.B) {
base := zap.New(
zap.NewJSONEncoder(),
zap.DebugLevel,
zap.Output(zap.Discard),
zap.DiscardOutput,
)
logger := zwrap.Sample(base, time.Second, 10, 10000)
b.ResetTimer()
Expand Down
6 changes: 3 additions & 3 deletions logger_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func withBenchedLogger(b *testing.B, f func(zap.Logger)) {
logger := zap.New(
zap.NewJSONEncoder(),
zap.DebugLevel,
zap.Output(zap.Discard),
zap.DiscardOutput,
)
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
Expand Down Expand Up @@ -144,7 +144,7 @@ func BenchmarkObjectField(b *testing.B) {
func BenchmarkAddCallerHook(b *testing.B) {
logger := zap.New(
zap.NewJSONEncoder(),
zap.Output(zap.Discard),
zap.DiscardOutput,
zap.AddCaller(),
)
b.ResetTimer()
Expand Down Expand Up @@ -177,7 +177,7 @@ func Benchmark100Fields(b *testing.B) {
logger := zap.New(
zap.NewJSONEncoder(),
zap.DebugLevel,
zap.Output(zap.Discard),
zap.DiscardOutput,
)

// Don't include allocating these helper slices in the benchmark. Since
Expand Down
8 changes: 6 additions & 2 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ import (
"sync"
)

// Discard is a convenience wrapper around ioutil.Discard.
var Discard = AddSync(ioutil.Discard)
var (
// Discard is a convenience wrapper around ioutil.Discard.
Discard = AddSync(ioutil.Discard)
// DiscardOutput is an Option that discards logger output.
DiscardOutput = Output(Discard)
)

// A WriteFlusher is an io.Writer that can also flush any buffered data.
type WriteFlusher interface {
Expand Down

0 comments on commit 92d6775

Please sign in to comment.