From 331eb51126b6046a9fcc075e84d482c028ab0411 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Tue, 7 Jul 2020 02:06:00 -0500 Subject: [PATCH] Add connection label to MySQL connects --- common/database.cpp | 6 +++--- common/database.h | 2 +- common/version.h | 2 +- world/main.cpp | 3 ++- zone/main.cpp | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/common/database.cpp b/common/database.cpp index ff52a196e..dbf4cabea 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -61,15 +61,15 @@ Database::Database(const char* host, const char* user, const char* passwd, const Connect(host, user, passwd, database, port); } -bool Database::Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port) { +bool Database::Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port, std::string connection_label) { uint32 errnum= 0; char errbuf[MYSQL_ERRMSG_SIZE]; if (!Open(host, user, passwd, database, port, &errnum, errbuf)) { - LogError("Failed to connect to database: Error: {}", errbuf); + LogError("[MySQL] Connection [{}] Failed to connect to database: Error [{}]", connection_label, errbuf); return false; } else { - LogInfo("Using database [{}] at [{}]:[{}]", database, host,port); + LogInfo("[MySQL] Connection [{}] database [{}] at [{}]:[{}]", connection_label, database, host,port); return true; } } diff --git a/common/database.h b/common/database.h index a7af5fc23..1d55484d5 100644 --- a/common/database.h +++ b/common/database.h @@ -100,7 +100,7 @@ class Database : public DBcore { public: Database(); Database(const char* host, const char* user, const char* passwd, const char* database,uint32 port); - bool Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port); + bool Connect(const char* host, const char* user, const char* passwd, const char* database, uint32 port, std::string connection_label = "default"); ~Database(); /* Character Creation */ diff --git a/common/version.h b/common/version.h index c840ebdc5..fb60b794e 100644 --- a/common/version.h +++ b/common/version.h @@ -34,7 +34,7 @@ * Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt */ -#define CURRENT_BINARY_DATABASE_VERSION 9153 +#define CURRENT_BINARY_DATABASE_VERSION 9154 #ifdef BOTS #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9027 diff --git a/world/main.cpp b/world/main.cpp index ad723a212..49e02859f 100644 --- a/world/main.cpp +++ b/world/main.cpp @@ -154,7 +154,8 @@ void LoadDatabaseConnections() Config->ContentDbUsername.c_str(), Config->ContentDbPassword.c_str(), Config->ContentDbName.c_str(), - Config->ContentDbPort + Config->ContentDbPort, + "content" )) { LogError("Cannot continue without a content database connection"); std::exit(1); diff --git a/zone/main.cpp b/zone/main.cpp index 3fbb6c8d7..7b5fca736 100644 --- a/zone/main.cpp +++ b/zone/main.cpp @@ -260,7 +260,8 @@ int main(int argc, char** argv) { Config->ContentDbUsername.c_str(), Config->ContentDbPassword.c_str(), Config->ContentDbName.c_str(), - Config->ContentDbPort + Config->ContentDbPort, + "content" )) { LogError("Cannot continue without a content database connection"); return 1;