1
0
mirror of https://github.com/golang/go synced 2024-11-20 05:54:43 -07: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' { if len(s) > 0 && s[len(s)-1] != '\n' {
buf.WriteByte('\n') buf.WriteByte('\n')
} }
_, err := std.out.Write(buf.Bytes()) _, err := l.out.Write(buf.Bytes())
return err return err
} }

View File

@ -74,3 +74,13 @@ func TestAll(t *testing.T) {
testPrint(t, testcase.flag, testcase.prefix, testcase.pattern, true) 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())
}
}