mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 18:04:13 +08:00
test: log error into stdout too.
This commit is contained in:
parent
4b2cb66453
commit
150f2c0afc
17
test/log.cc
17
test/log.cc
@ -106,24 +106,23 @@ bool output(loglevel priority, const char *format, va_list ap) {
|
|||||||
if (rc != MDB_SUCCESS)
|
if (rc != MDB_SUCCESS)
|
||||||
failure_perror("localtime_r()", rc);
|
failure_perror("localtime_r()", rc);
|
||||||
|
|
||||||
last = (priority >= error) ? stderr : stdout;
|
last = stdout;
|
||||||
fprintf(last,
|
fprintf(last,
|
||||||
"[ %02d%02d%02d-%02d:%02d:%02d.%06d_%05u %-10s %.4s ] %s" /* TODO */,
|
"[ %02d%02d%02d-%02d:%02d:%02d.%06d_%05u %-10s %.4s ] %s" /* TODO */,
|
||||||
tm.tm_year - 100, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min,
|
tm.tm_year - 100, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min,
|
||||||
tm.tm_sec, chrono::fractional2us(now.fractional), osal_getpid(),
|
tm.tm_sec, chrono::fractional2us(now.fractional), osal_getpid(),
|
||||||
prefix.c_str(), level2str(priority), suffix.c_str());
|
prefix.c_str(), level2str(priority), suffix.c_str());
|
||||||
vfprintf(last, format, ap);
|
vfprintf(last, format, ap);
|
||||||
|
|
||||||
size_t len = strlen(format);
|
size_t len = strlen(format);
|
||||||
char end = len ? format[len - 1] : '\0';
|
char end = len ? format[len - 1] : '\0';
|
||||||
|
|
||||||
switch (end) {
|
switch (end) {
|
||||||
default:
|
default:
|
||||||
putc('\n', last);
|
putc('\n', last);
|
||||||
case '\n':
|
case '\n':
|
||||||
fflush(last);
|
fflush(last);
|
||||||
last = nullptr;
|
last = nullptr;
|
||||||
if (priority > info)
|
|
||||||
fflushall();
|
|
||||||
case ' ':
|
case ' ':
|
||||||
case '_':
|
case '_':
|
||||||
case ':':
|
case ':':
|
||||||
@ -135,6 +134,16 @@ bool output(loglevel priority, const char *format, va_list ap) {
|
|||||||
case '\0':
|
case '\0':
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (priority >= error && last != stderr) {
|
||||||
|
fprintf(stderr, "[ %05u %-10s %.4s ] %s", osal_getpid(), prefix.c_str(),
|
||||||
|
level2str(priority), suffix.c_str());
|
||||||
|
vfprintf(stderr, format, ap);
|
||||||
|
if (end != '\n')
|
||||||
|
putc('\n', stderr);
|
||||||
|
fflush(stderr);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user