Skip to content

Commit

Permalink
Added some logging
Browse files Browse the repository at this point in the history
  • Loading branch information
rds1983 committed Nov 29, 2024
1 parent 9eb4077 commit 45ee5ab
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 1 deletion.
9 changes: 9 additions & 0 deletions AssetManagementBase/AMBConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace AssetManagementBase
{
public static class AMBConfiguration
{
public static Action<string> Logger;
}
}
2 changes: 1 addition & 1 deletion AssetManagementBase/AssetManagementBase.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/rds1983/AssetManagementBase</PackageProjectUrl>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>0.6.7</Version>
<Version>0.6.8</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Expand Down
5 changes: 5 additions & 0 deletions AssetManagementBase/AssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public T UseLoader<T>(AssetLoader<T> 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)
Expand Down
2 changes: 2 additions & 0 deletions AssetManagementBase/AssetManagerCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ internal class AssetManagerCore
{
private readonly IAssetAccessor _assetAccessor;

public string Name => _assetAccessor.Name;

public Dictionary<string, object> Cache { get; } = new Dictionary<string, object>();

public AssetManagerCore(IAssetAccessor assetOpener)
Expand Down
3 changes: 3 additions & 0 deletions AssetManagementBase/FileAssetAccessor.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using AssetManagementBase.Utility;
using System;
using System.IO;
using System.Reflection;

namespace AssetManagementBase
{
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
Expand Down
2 changes: 2 additions & 0 deletions AssetManagementBase/IAssetAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ namespace AssetManagementBase
{
public interface IAssetAccessor
{
string Name { get; }

bool Exists(string assetName);
Stream Open(string assetName);
}
Expand Down
2 changes: 2 additions & 0 deletions AssetManagementBase/ResourceAssetAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ internal class ResourceAssetAccessor: IAssetAccessor
private readonly string _prefix;
private readonly HashSet<string> _resourceNames;

public string Name => $"Res:{_assembly.GetName().Name}/{_prefix}";

public ResourceAssetAccessor(Assembly assembly, string prefix, bool prependAssemblyName)
{
_assembly = assembly ?? throw new ArgumentNullException(nameof(assembly));
Expand Down

0 comments on commit 45ee5ab

Please sign in to comment.