Use streamDebugColored IOC variable instead
This commit is contained in:
@ -198,6 +198,7 @@ public:
|
||||
extern "C" { // needed for Windows
|
||||
epicsExportAddress(int, streamDebug);
|
||||
epicsExportAddress(int, streamError);
|
||||
epicsExportAddress(int, streamDebugColored);
|
||||
}
|
||||
|
||||
// for subroutine record
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <errlog.h>
|
||||
#include <epicsStdio.h>
|
||||
|
||||
int streamDebug = 0;
|
||||
int streamError = 1;
|
||||
@ -71,8 +70,12 @@ static bool win_console_init() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* true if console supports ANSI color codes */
|
||||
static bool win_console_colored = win_console_init();
|
||||
/* do isatty() call second as always want to run win_console_init() */
|
||||
int streamDebugColored = win_console_init() && _isatty(_fileno(stdout));
|
||||
|
||||
#else
|
||||
|
||||
int streamDebugColored = isatty(fileno(stdout));
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
@ -158,22 +161,5 @@ const char* ansiEscape(AnsiMode mode)
|
||||
{
|
||||
static const char* AnsiEscapes[] = { "\033[7m", "\033[27m", "\033[47m",
|
||||
"\033[0m", "\033[31;1m" };
|
||||
static const char* stream_debug_color = getenv("STREAM_DEBUG_COLOR");
|
||||
bool color_output = false;
|
||||
if (stream_debug_color == NULL || stream_debug_color[0] == 'A'||
|
||||
stream_debug_color[0] == 'a') // auto
|
||||
{
|
||||
#ifdef _WIN32
|
||||
color_output = win_console_colored &&
|
||||
_isatty(_fileno(epicsGetStdout()));
|
||||
#else
|
||||
color_output = isatty(fileno(epicsGetStdout()));
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
else if (stream_debug_color[0] == 'Y' || stream_debug_color[0] == 'y' ||
|
||||
stream_debug_color[0] == '1') // yes
|
||||
{
|
||||
color_output = true;
|
||||
}
|
||||
return color_output ? AnsiEscapes[mode] : "";
|
||||
return streamDebugColored ? AnsiEscapes[mode] : "";
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
extern int streamDebug;
|
||||
extern int streamError;
|
||||
extern int streamDebugColored;
|
||||
extern void (*StreamPrintTimestampFunction)(char* buffer, size_t size);
|
||||
|
||||
void StreamError(int line, const char* file, const char* fmt, ...)
|
||||
|
@ -32,6 +32,7 @@ if (@ARGV[0] eq "-3.13") {
|
||||
} else {
|
||||
print "variable(streamDebug, int)\n";
|
||||
print "variable(streamError, int)\n";
|
||||
print "variable(streamDebugColored, int)\n";
|
||||
print "registrar(streamRegistrar)\n";
|
||||
if ($asyn) { print "registrar(AsynDriverInterfaceRegistrar)\n"; }
|
||||
}
|
||||
|
Reference in New Issue
Block a user