Skip to content

Commit c7138bb

Browse files
committedMar 3, 2017
Fixed bug where STDLogSink would wrap to bogus values when redirecting stdout to anything but a pty
1 parent 1302ddd commit c7138bb

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed
 

‎STDLogSink.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,16 @@ STDLogSink::STDLogSink(Severity min_severity)
4545
{
4646
//Get the current display terminal width
4747
#ifndef _WIN32
48-
struct winsize w;
49-
ioctl(0, TIOCGWINSZ, &w);
50-
m_termWidth = w.ws_col;
48+
if(isatty(stdout))
49+
{
50+
struct winsize w;
51+
ioctl(0, TIOCGWINSZ, &w);
52+
m_termWidth = w.ws_col;
53+
}
54+
else
55+
{
56+
m_termWidth = 120; //reasonable default width for file logging
57+
}
5158
#else
5259
CONSOLE_SCREEN_BUFFER_INFO csbi;
5360
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);

0 commit comments

Comments
 (0)
Please sign in to comment.