]> Cypherpunks repositories - gostls13.git/commitdiff
log: fix custom output bug
authorAndrew Gerrand <adg@golang.org>
Fri, 15 Oct 2010 00:55:51 +0000 (11:55 +1100)
committerAndrew Gerrand <adg@golang.org>
Fri, 15 Oct 2010 00:55:51 +0000 (11:55 +1100)
R=r
CC=golang-dev
https://golang.org/cl/2525041

src/pkg/log/log.go
src/pkg/log/log_test.go

index b52458a935f0d2203234997f8cb209a589dd397e..50c01a3d350bfafe2c9f3cbba46e476345c6f93f 100644 (file)
@@ -136,7 +136,7 @@ func (l *Logger) Output(calldepth int, s string) os.Error {
        if len(s) > 0 && s[len(s)-1] != '\n' {
                buf.WriteByte('\n')
        }
-       _, err := std.out.Write(buf.Bytes())
+       _, err := l.out.Write(buf.Bytes())
        return err
 }
 
index 0a5753f3a911515e1aeefdf6ae3c59f2e53da59e..67c0452dc3fa6b86cd4957375737d0781f987f45 100644 (file)
@@ -74,3 +74,13 @@ func TestAll(t *testing.T) {
                testPrint(t, testcase.flag, testcase.prefix, testcase.pattern, true)
        }
 }
+
+func TestOutput(t *testing.T) {
+       const testString = "test"
+       var b bytes.Buffer
+       l := New(&b, "", 0)
+       l.Println(testString)
+       if expect := testString + "\n"; b.String() != expect {
+               t.Errorf("log output should match %q is %q", expect, b.String())
+       }
+}