Skip to content

Commit

Permalink
Fix tests for darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
kylelemons committed Feb 25, 2012
1 parent f065bb0 commit 6f2f251
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion log4go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"io/ioutil"
"os"
"runtime"
"syscall"
"testing"
"time"
)
Expand Down Expand Up @@ -437,14 +436,17 @@ func BenchmarkFormatLogRecord(b *testing.B) {
}

func BenchmarkConsoleLog(b *testing.B) {
/* This doesn't seem to work on OS X
sink, err := os.Open(os.DevNull)
if err != nil {
panic(err)
}
if err := syscall.Dup2(int(sink.Fd()), syscall.Stdout); err != nil {
panic(err)
}
*/

stdout = ioutil.Discard
sl := NewDefaultLogger(INFO)
for i := 0; i < b.N; i++ {
sl.Log(WARNING, "here", "This is a log message")
Expand Down
4 changes: 3 additions & 1 deletion termlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import (
"fmt"
)

var stdout io.Writer = os.Stdout

// This is the standard writer that prints to standard output.
type ConsoleLogWriter chan *LogRecord

// This creates a new ConsoleLogWriter
func NewConsoleLogWriter() ConsoleLogWriter {
records := make(ConsoleLogWriter, LogBufferLength)
go records.run(os.Stdout)
go records.run(stdout)
return records
}

Expand Down

0 comments on commit 6f2f251

Please sign in to comment.