Skip to content

Commit 797e8ec

Browse files
authored
Revert "gtest IT: print logs to stderr unconditionally" (#469)
This reverts commits that introduced unconditional logging to stderr in gtest integration tests: - 6b9b545, - 2db8a26, - 7ffd093. Rationale: CI got unstable because two tests that issue many requests (~4000) now timeout every time, because stderr logging (unbuffered!) of each request is too slow. I'm unable to think of a better way to capture logs in CI, so I'm reverting the change for now and will hopefully look into a more robust solution later.
2 parents 9fe3acd + 048aa68 commit 797e8ec

1 file changed

Lines changed: 1 addition & 34 deletions

File tree

tests/src/integration/logger.cpp

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,9 @@ using namespace test::driver;
3232
#ifdef _WIN32
3333
#define FILE_MODE 0
3434
#define LOCALTIME(tm, time) localtime_s(tm, time)
35-
#define GMTIME(tm, time) gmtime_s(tm, time)
36-
#include <io.h>
37-
#define IS_STDERR_TTY() _isatty(_fileno(stderr))
3835
#else
3936
#define FILE_MODE S_IRWXU | S_IRWXG | S_IROTH
4037
#define LOCALTIME(tm, time) localtime_r(time, tm)
41-
#define GMTIME(tm, time) gmtime_r(time, tm)
42-
#include <unistd.h>
43-
#define IS_STDERR_TTY() isatty(STDERR_FILENO)
4438
#endif
4539

4640
Logger::Logger()
@@ -131,34 +125,7 @@ void Logger::log(const CassLogMessage* log, void* data) {
131125
// Create the formatted log message and output to the file
132126
std::string severity = cass_log_level_string(log->severity);
133127
logger->output_ << date.str() << " " << time.str() << " " << severity << ": " << message << " ("
134-
<< log->file << ":" << log->line << ") " << std::endl;
135-
136-
// Also log to stderr so that CI output captures driver logs in real-time.
137-
static bool use_color = IS_STDERR_TTY();
138-
const char* color = "";
139-
const char* reset = "";
140-
const char* dim = "";
141-
if (use_color) {
142-
reset = "\033[0m";
143-
dim = "\033[2m";
144-
switch (log->severity) {
145-
case CASS_LOG_TRACE: color = "\033[35m"; break;
146-
case CASS_LOG_DEBUG: color = "\033[34m"; break;
147-
case CASS_LOG_INFO: color = "\033[32m"; break;
148-
case CASS_LOG_WARN: color = "\033[33m"; break;
149-
default: color = "\033[31m"; break;
150-
}
151-
}
152-
cass_uint64_t const epoch_secs = log->time_ms / 1000;
153-
unsigned short const ms = log->time_ms % 1000;
154-
time_t const raw = static_cast<time_t>(epoch_secs);
155-
struct tm utc;
156-
GMTIME(&utc, &raw);
157-
char ts[24];
158-
strftime(ts, sizeof(ts), "%Y-%m-%dT%H:%M:%S", &utc);
159-
std::cerr << ts << "." << std::setfill('0') << std::setw(3) << ms << "Z" << " [" << color << severity << reset << "] "
160-
<< dim << "(" << log->file << ":" << log->line << ")" << reset
161-
<< " " << message << std::endl;
128+
<< log->file << ":" << log->line << ") " << std::endl;
162129

163130
// Determine if the log message matches any of the criteria
164131
for (std::vector<std::string>::const_iterator iterator = logger->search_criteria_.begin();

0 commit comments

Comments
 (0)