From 952e6e5496a012ab0d6927e13a0f9762927a51ec Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Tue, 16 Nov 2021 03:30:33 +0700 Subject: [PATCH] Add logging to `DBAPI` --- sources/Data/Database/DBAPI.uc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sources/Data/Database/DBAPI.uc b/sources/Data/Database/DBAPI.uc index 3f2ddd3..29314e9 100644 --- a/sources/Data/Database/DBAPI.uc +++ b/sources/Data/Database/DBAPI.uc @@ -27,6 +27,10 @@ var private const class localDBClass; // separately. var private AssociativeArray loadedLocalDatabases; +var private LoggerAPI.Definition infoLocalDatabaseCreated; +var private LoggerAPI.Definition infoLocalDatabaseDeleted; +var private LoggerAPI.Definition infoLocalDatabaseLoaded; + private final function CreateLocalDBMapIfMissing() { if (loadedLocalDatabases == none) { @@ -139,6 +143,7 @@ public final function LocalDatabaseInstance NewLocal(Text databaseName) newConfig.SetRootName(rootRecordName); newConfig.Save(); newLocalDBInstance.Initialize(newConfig, rootRecord); + _.logger.Auto(infoLocalDatabaseCreated).Arg(databaseName.Copy()); _.memory.Free(rootRecordName); return newLocalDBInstance; } @@ -193,6 +198,7 @@ public final function LocalDatabaseInstance LoadLocal(Text databaseName) newConfig.Save(); } newLocalDBInstance.Initialize(newConfig, rootRecord); + _.logger.Auto(infoLocalDatabaseLoaded).Arg(databaseName.Copy()); _.memory.Free(rootRecordName); return newLocalDBInstance; } @@ -234,9 +240,11 @@ public final function bool DeleteLocal(Text databaseName) // to allow it to clean up safely _.memory.Free(dbEntry.key); _.memory.Free(dbEntry.value); - if (localDatabaseConfig != none) { + if (localDatabaseConfig != none) + { EraseAllPackageData(localDatabaseConfig.GetPackageName()); localDatabaseConfig.DeleteSelf(); + _.logger.Auto(infoLocalDatabaseDeleted).Arg(databaseName.Copy()); return true; } return false; @@ -290,4 +298,7 @@ public final function array ListLocal() defaultproperties { localDBClass = class'LocalDatabaseInstance' + infoLocalDatabaseCreated = (l=LOG_Info,m="Local database \"%1\" was created.") + infoLocalDatabaseLoaded = (l=LOG_Info,m="Local database \"%1\" was loaded.") + infoLocalDatabaseDeleted = (l=LOG_Info,m="Local database \"%1\" was deleted.") } \ No newline at end of file