diff --git a/AssetManagementBase/AMBConfiguration.cs b/AssetManagementBase/AMBConfiguration.cs new file mode 100644 index 0000000..41b3c94 --- /dev/null +++ b/AssetManagementBase/AMBConfiguration.cs @@ -0,0 +1,9 @@ +using System; + +namespace AssetManagementBase +{ + public static class AMBConfiguration + { + public static Action Logger; + } +} diff --git a/AssetManagementBase/AssetManagementBase.csproj b/AssetManagementBase/AssetManagementBase.csproj index 6230b74..5d2a6e4 100644 --- a/AssetManagementBase/AssetManagementBase.csproj +++ b/AssetManagementBase/AssetManagementBase.csproj @@ -6,7 +6,7 @@ MIT https://github.com/rds1983/AssetManagementBase netstandard2.0 - 0.6.7 + 0.6.8 diff --git a/AssetManagementBase/AssetManager.cs b/AssetManagementBase/AssetManager.cs index 94accdb..7243ad5 100644 --- a/AssetManagementBase/AssetManager.cs +++ b/AssetManagementBase/AssetManager.cs @@ -84,6 +84,11 @@ public T UseLoader(AssetLoader loader, string assetName, IAssetSettings se } } + if (AMBConfiguration.Logger != null) + { + AMBConfiguration.Logger($"AMB: Loading asset '{assetName}' of type '{typeof(T).Name}' from '{_core.Name}'"); + } + var result = loader(assetManager, assetName, settings, tag); if (storeInCache) diff --git a/AssetManagementBase/AssetManagerCore.cs b/AssetManagementBase/AssetManagerCore.cs index 753942b..223f16d 100644 --- a/AssetManagementBase/AssetManagerCore.cs +++ b/AssetManagementBase/AssetManagerCore.cs @@ -8,6 +8,8 @@ internal class AssetManagerCore { private readonly IAssetAccessor _assetAccessor; + public string Name => _assetAccessor.Name; + public Dictionary Cache { get; } = new Dictionary(); public AssetManagerCore(IAssetAccessor assetOpener) diff --git a/AssetManagementBase/FileAssetAccessor.cs b/AssetManagementBase/FileAssetAccessor.cs index 106f3e4..72be323 100644 --- a/AssetManagementBase/FileAssetAccessor.cs +++ b/AssetManagementBase/FileAssetAccessor.cs @@ -1,6 +1,7 @@ using AssetManagementBase.Utility; using System; using System.IO; +using System.Reflection; namespace AssetManagementBase { @@ -8,6 +9,8 @@ internal class FileAssetAccessor : IAssetAccessor { private readonly string _baseFolder; + public string Name => $"File:{_baseFolder}"; + public FileAssetAccessor(string baseFolder) { // Base folder shouldn't have separator char at the end diff --git a/AssetManagementBase/IAssetAccessor.cs b/AssetManagementBase/IAssetAccessor.cs index 3fb119b..ab6eb8e 100644 --- a/AssetManagementBase/IAssetAccessor.cs +++ b/AssetManagementBase/IAssetAccessor.cs @@ -4,6 +4,8 @@ namespace AssetManagementBase { public interface IAssetAccessor { + string Name { get; } + bool Exists(string assetName); Stream Open(string assetName); } diff --git a/AssetManagementBase/ResourceAssetAccessor.cs b/AssetManagementBase/ResourceAssetAccessor.cs index 55ab76b..4b2b237 100644 --- a/AssetManagementBase/ResourceAssetAccessor.cs +++ b/AssetManagementBase/ResourceAssetAccessor.cs @@ -12,6 +12,8 @@ internal class ResourceAssetAccessor: IAssetAccessor private readonly string _prefix; private readonly HashSet _resourceNames; + public string Name => $"Res:{_assembly.GetName().Name}/{_prefix}"; + public ResourceAssetAccessor(Assembly assembly, string prefix, bool prependAssemblyName) { _assembly = assembly ?? throw new ArgumentNullException(nameof(assembly));