Replace 'mysql_query_t' with macro logging location

pull/4588/head
Javier Jaramago Fernández 2 years ago
parent d9cf9195ff
commit a0841714e5

@ -199,8 +199,8 @@ std::size_t count_matches(const string& str, const string& substr) {
return result;
}
int mysql_query_t(MYSQL* mysql, const char* query) {
diag("%s: Issuing query '%s' to ('%s':%d)", get_formatted_time().c_str(), query, mysql->host, mysql->port);
int mysql_query_t__(MYSQL* mysql, const char* query, const char* f, int ln, const char* fn) {
diag("%s:%d:%s(): Issuing query '%s' to ('%s':%d)", f, ln, fn, query, mysql->host, mysql->port);
return mysql_query(mysql, query);
}

@ -68,7 +68,18 @@ inline std::string get_formatted_time() {
return std::string(__buffer);
}
int mysql_query_t(MYSQL* mysql, const char* query);
/**
* @brief Wrapper for 'mysql_query' with logging for convenience.
* @details Should be used through 'mysql_query_t' macro.
* @return Result of calling 'mysql_query'.
*/
int mysql_query_t__(MYSQL* mysql, const char* query, const char* f, int ln, const char* fn);
/**
* @brief Convenience macro with query logging.
*/
#define mysql_query_t(mysql, query)\
mysql_query_t__(mysql, query, __FILE__, __LINE__, __func__)
#define MYSQL_QUERY(mysql, query) \
do { \

Loading…
Cancel
Save