Skip to content

Commit

Permalink
Fixed bug where STDLogSink would wrap to bogus values when redirectin…
Browse files Browse the repository at this point in the history
…g stdout to anything but a pty
azonenberg committed Mar 3, 2017
1 parent 1302ddd commit c7138bb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions STDLogSink.cpp
Original file line number Diff line number Diff line change
@@ -45,9 +45,16 @@ STDLogSink::STDLogSink(Severity min_severity)
{
//Get the current display terminal width
#ifndef _WIN32
struct winsize w;
ioctl(0, TIOCGWINSZ, &w);
m_termWidth = w.ws_col;
if(isatty(stdout))
{
struct winsize w;
ioctl(0, TIOCGWINSZ, &w);
m_termWidth = w.ws_col;
}
else
{
m_termWidth = 120; //reasonable default width for file logging
}
#else
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);

0 comments on commit c7138bb

Please sign in to comment.