Added temporal helper function to write timestamps in test

pull/2833/head
Javier Jaramago Fernández 6 years ago
parent 8727282cfb
commit 5ecb68d0d6

@ -1,4 +1,5 @@
#include <string>
#include <cstring>
#include <mysql.h>
#include "tap.h"
@ -109,6 +110,38 @@ int get_server_version(MYSQL *mysql, std::string& version) {
return 0;
}
void proxy_info_(const char* msg, ...) {
va_list args;
va_start(args, msg);
time_t __timer;
char __buffer[25];
// create the time info
struct tm *__tm_info;
time(&__timer);
__tm_info = localtime(&__timer);
strftime(__buffer, 25, "%Y-%m-%d %H:%M:%S", __tm_info);
// format the message
#ifdef DEBUG
const char* debug_msg_fmt = " %s:%d:%s(): [INFO] ";
#else
const char* debug_msg_fmt = " [INFO]";
#endif /* DEBUG */
std::size_t msg_len = strlen(msg);
char* str_buf = (char*)malloc(25 + strlen(debug_msg_fmt) + msg_len + 1);
strcpy(str_buf, __buffer);
strcat(str_buf, debug_msg_fmt);
strcat(str_buf, msg);
vfprintf(stderr, str_buf, args);
free(str_buf);
va_end(args);
}
int kill_child_proc(pid_t child_pid, const uint timeout_us, const uint it_sleep_us) {
uint err = 0;
uint waited = 0;

@ -28,6 +28,8 @@ int select_config_file(MYSQL* mysql, std::string& resultset);
}
#endif
void proxy_info_(const char* msg, ...);
/**
* @brief Simple struct that holds the 'timeout options' for 'wexecvp'.
*/

Loading…
Cancel
Save