Commit 568eccd1 authored by Andrew Gerrand's avatar Andrew Gerrand

log: fix custom output bug

R=r
CC=golang-dev
https://golang.org/cl/2525041
parent 0b2af925
...@@ -136,7 +136,7 @@ func (l *Logger) Output(calldepth int, s string) os.Error { ...@@ -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
} }
......
...@@ -74,3 +74,13 @@ func TestAll(t *testing.T) { ...@@ -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())
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment