mirror of
https://github.com/golang/go
synced 2024-11-21 18:24:46 -07:00
log: fix custom output bug
R=r CC=golang-dev https://golang.org/cl/2525041
This commit is contained in:
parent
0b2af925db
commit
568eccd12d
@ -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) {
|
|||||||
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())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user