Read from LoggingPipe returns error
This commit is contained in:
parent
27634423d9
commit
0cabc5f112
1 changed files with 5 additions and 7 deletions
|
|
@ -41,13 +41,11 @@ impl LoggingPipe {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Read for LoggingPipe {
|
impl Read for LoggingPipe {
|
||||||
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
|
fn read(&mut self, _: &mut [u8]) -> std::io::Result<usize> {
|
||||||
// NOTE: should we do this? I think if anyone were to chain LoggingPipe and read from it,
|
Err(std::io::Error::new(
|
||||||
// they would see very weird behavior because we drain self.buffer in `flush`. Also, logs would be screwed up.
|
std::io::ErrorKind::Other,
|
||||||
// Consider removing this code.
|
"Can not reed from a LoggingPipe",
|
||||||
let amt = std::cmp::min(buf.len(), self.buffer.len());
|
))
|
||||||
let data: Vec<_> = self.buffer.drain(..amt).collect();
|
|
||||||
buf.as_mut().write(&data)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue