1
0
mirror of https://github.com/golang/go synced 2024-10-03 06:21:21 -06:00

log: fix custom output bug

R=r
CC=golang-dev
https://golang.org/cl/2525041
This commit is contained in:
Andrew Gerrand 2010-10-15 11:55:51 +11:00
parent 0b2af925db
commit 568eccd12d
2 changed files with 11 additions and 1 deletions

View 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
}

View 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())
}
}