Rebrand
This commit is contained in:
@@ -14,27 +14,27 @@ let persistentDatabaseConnection = null;
|
||||
// ===========================================================================
|
||||
|
||||
function initDatabaseScript() {
|
||||
logToConsole(LOG_INFO, "[Asshat.Database]: Initializing database script ...");
|
||||
logToConsole(LOG_INFO, "[VRR.Database]: Initializing database script ...");
|
||||
databaseConfig = loadDatabaseConfiguration();
|
||||
logToConsole(LOG_INFO, "[Asshat.Database]: Database script initialized successfully!");
|
||||
logToConsole(LOG_INFO, "[VRR.Database]: Database script initialized successfully!");
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
function connectToDatabase() {
|
||||
if(persistentDatabaseConnection == null) {
|
||||
logToConsole(LOG_DEBUG, "[Asshat.Database] Initializing database connection ...");
|
||||
logToConsole(LOG_DEBUG, "[VRR.Database] Initializing database connection ...");
|
||||
persistentDatabaseConnection = module.mysql.connect(databaseConfig.host, databaseConfig.user, databaseConfig.pass, databaseConfig.name, databaseConfig.port);
|
||||
if(persistentDatabaseConnection.error) {
|
||||
console.warn("[Asshat.Database] Database connection error: " + toString(persistentDatabaseConnection.error));
|
||||
console.warn("[VRR.Database] Database connection error: " + toString(persistentDatabaseConnection.error));
|
||||
persistentDatabaseConnection = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
logToConsole(LOG_DEBUG, "[Asshat.Database] Database connection successful!");
|
||||
logToConsole(LOG_DEBUG, "[VRR.Database] Database connection successful!");
|
||||
return persistentDatabaseConnection;
|
||||
} else {
|
||||
logToConsole(LOG_DEBUG, "[Asshat.Database] Using existing database connection.");
|
||||
logToConsole(LOG_DEBUG, "[VRR.Database] Using existing database connection.");
|
||||
return persistentDatabaseConnection;
|
||||
}
|
||||
}
|
||||
@@ -45,9 +45,9 @@ function disconnectFromDatabase(dbConnection) {
|
||||
if(!databaseConfig.usePersistentConnection) {
|
||||
try {
|
||||
dbConnection.close();
|
||||
logToConsole(LOG_DEBUG, `[Asshat.Database] Database connection closed successfully`);
|
||||
logToConsole(LOG_DEBUG, `[VRR.Database] Database connection closed successfully`);
|
||||
} catch(error) {
|
||||
logToConsole(LOG_ERROR, `[Asshat.Database] Database connection could not be closed! (Error: ${error})`);
|
||||
logToConsole(LOG_ERROR, `[VRR.Database] Database connection could not be closed! (Error: ${error})`);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -56,7 +56,7 @@ function disconnectFromDatabase(dbConnection) {
|
||||
// ===========================================================================
|
||||
|
||||
function queryDatabase(dbConnection, queryString) {
|
||||
logToConsole(LOG_DEBUG, `[Asshat.Database] Query string: ${queryString}`);
|
||||
logToConsole(LOG_DEBUG, `[VRR.Database] Query string: ${queryString}`);
|
||||
return dbConnection.query(queryString);
|
||||
}
|
||||
|
||||
@@ -112,19 +112,19 @@ function quickDatabaseQuery(queryString) {
|
||||
let dbConnection = connectToDatabase();
|
||||
let insertId = 0;
|
||||
if(dbConnection) {
|
||||
logToConsole(LOG_DEBUG, `[Asshat.Database] Query string: ${queryString}`);
|
||||
logToConsole(LOG_DEBUG, `[VRR.Database] Query string: ${queryString}`);
|
||||
let dbQuery = queryDatabase(dbConnection, queryString);
|
||||
if(getDatabaseInsertId(dbConnection)) {
|
||||
insertId = getDatabaseInsertId(dbConnection);
|
||||
logToConsole(LOG_DEBUG, `[Asshat.Database] Query returned insert id ${insertId}`);
|
||||
logToConsole(LOG_DEBUG, `[VRR.Database] Query returned insert id ${insertId}`);
|
||||
}
|
||||
|
||||
if(dbQuery) {
|
||||
try {
|
||||
freeDatabaseQuery(dbQuery);
|
||||
logToConsole(LOG_DEBUG, `[Asshat.Database] Query result free'd successfully`);
|
||||
logToConsole(LOG_DEBUG, `[VRR.Database] Query result free'd successfully`);
|
||||
} catch(error) {
|
||||
logToConsole(LOG_ERROR, `[Asshat.Database] Query result could not be free'd! (Error: ${error})`);
|
||||
logToConsole(LOG_ERROR, `[VRR.Database] Query result could not be free'd! (Error: ${error})`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,9 +176,9 @@ function setConstantsAsGlobalVariablesInDatabase() {
|
||||
let dbConnection = connectToDatabase();
|
||||
let entries = Object.entries(global);
|
||||
for(let i in entries) {
|
||||
logToConsole(LOG_DEBUG, `[Asshat.Database] Checking entry ${i} (${entries[i]})`);
|
||||
if(toString(i).slice(0, 3).indexOf("AG_") != -1) {
|
||||
logToConsole(LOG_DEBUG, `[Asshat.Database] Adding ${i} (${entries[i]}) to database global variables`);
|
||||
logToConsole(LOG_DEBUG, `[VRR.Database] Checking entry ${i} (${entries[i]})`);
|
||||
if(toString(i).slice(0, 3).indexOf("VRR_") != -1) {
|
||||
logToConsole(LOG_DEBUG, `[VRR.Database] Adding ${i} (${entries[i]}) to database global variables`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user