Anonymized collection names for log

This commit is contained in:
Ottermandias 2022-07-13 16:58:27 +02:00
parent b5698acebf
commit 1c60a61f79
5 changed files with 21 additions and 22 deletions

View file

@ -108,12 +108,12 @@ public partial class ModCollection
}
PluginLog.Debug( "[{Thread}] Recalculating effective file list for {CollectionName:l}",
Thread.CurrentThread.ManagedThreadId, Name );
Thread.CurrentThread.ManagedThreadId, AnonymizedName );
_cache ??= new Cache( this );
_cache.FullRecalculation();
PluginLog.Debug( "[{Thread}] Recalculation of effective file list for {CollectionName:l} finished.",
Thread.CurrentThread.ManagedThreadId, Name );
Thread.CurrentThread.ManagedThreadId, AnonymizedName );
}
// Set Metadata files.

View file

@ -81,7 +81,7 @@ public partial class ModCollection
collection.ModSettingChanged += OnInheritedModSettingChange;
collection.InheritanceChanged += OnInheritedInheritanceChange;
InheritanceChanged.Invoke( false );
PluginLog.Debug( "Added {InheritedName:l} to {Name:l} inheritances.", collection.Name, Name );
PluginLog.Debug( "Added {InheritedName:l} to {Name:l} inheritances.", collection.AnonymizedName, AnonymizedName );
return true;
}
@ -92,7 +92,7 @@ public partial class ModCollection
inheritance.InheritanceChanged -= OnInheritedInheritanceChange;
_inheritance.RemoveAt( idx );
InheritanceChanged.Invoke( false );
PluginLog.Debug( "Removed {InheritedName:l} from {Name:l} inheritances.", inheritance.Name, Name );
PluginLog.Debug( "Removed {InheritedName:l} from {Name:l} inheritances.", inheritance.AnonymizedName, AnonymizedName );
}
// Order in the inheritance list is relevant.
@ -101,7 +101,7 @@ public partial class ModCollection
if( _inheritance.Move( from, to ) )
{
InheritanceChanged.Invoke( false );
PluginLog.Debug( "Moved {Name:l}s inheritance {From} to {To}.", Name, from, to );
PluginLog.Debug( "Moved {Name:l}s inheritance {From} to {To}.", AnonymizedName, from, to );
}
}

View file

@ -22,6 +22,11 @@ public partial class ModCollection
// The collection name can contain invalid path characters,
// but after removing those and going to lower case it has to be unique.
public string Name { get; private init; }
// Get the first two letters of a collection name and its Index (or None if it is the empty collection).
public string AnonymizedName
=> this == Empty ? Empty.Name : Name.Length > 2 ? $"{Name[..2]}... ({Index})" : $"{Name} ({Index})";
public int Version { get; private set; }
public int Index { get; private set; } = -1;

View file

@ -28,7 +28,7 @@ public unsafe partial class ResourceLoader
{
if( handle != null )
{
PluginLog.Information( "[ResourceLoader] Destructing Resource Handle {Path:l} at 0x{Address:X} (Refcount {Refcount}) .",
PluginLog.Information( "[ResourceLoader] Destructing Resource Handle {Path:l} at 0x{Address:X} (Refcount {Refcount}).",
handle->FileName, ( ulong )handle, handle->RefCount );
}

View file

@ -436,42 +436,36 @@ public class Penumbra : IDalamudPlugin
ModManager.Sum( m => m.TotalManipulations ) );
sb.AppendFormat( "> **`IMC Exceptions Thrown: `** {0}\n", ImcExceptions );
string CollectionName( ModCollection c )
=> c == ModCollection.Empty ? ModCollection.Empty.Name : c.Name.Length >= 2 ? c.Name[ ..2 ] : c.Name;
string CharacterName( string name )
=> string.Join( " ", name.Split().Select( n => $"{n[ 0 ]}." ) ) + ':';
void PrintCollection( ModCollection c )
=> sb.AppendFormat( "**Collection {0}... ({1})**\n"
+ "> **`Inheritances: `** {2}\n"
+ "> **`Enabled Mods: `** {3}\n"
+ "> **`Total Conflicts: `** {4}\n"
+ "> **`Solved Conflicts: `** {5}\n",
CollectionName( c ), c.Index, c.Inheritance.Count, c.ActualSettings.Count( s => s is { Enabled: true } ),
=> sb.AppendFormat( "**Collection {0}**\n"
+ "> **`Inheritances: `** {1}\n"
+ "> **`Enabled Mods: `** {2}\n"
+ "> **`Total Conflicts: `** {3}\n"
+ "> **`Solved Conflicts: `** {4}\n",
c.AnonymizedName, c.Inheritance.Count, c.ActualSettings.Count( s => s is { Enabled: true } ),
c.AllConflicts.SelectMany( x => x ).Sum( x => x.HasPriority ? 0 : x.Conflicts.Count ),
c.AllConflicts.SelectMany( x => x ).Sum( x => x.HasPriority || !x.Solved ? 0 : x.Conflicts.Count ) );
sb.AppendLine( "**Collections**" );
sb.AppendFormat( "> **`#Collections: `** {0}\n", CollectionManager.Count - 1 );
sb.AppendFormat( "> **`Active Collections: `** {0}\n", CollectionManager.Count( c => c.HasCache ) );
sb.AppendFormat( "> **`Default Collection: `** {0}... ({1})\n", CollectionName( CollectionManager.Default ),
CollectionManager.Default.Index );
sb.AppendFormat( "> **`Current Collection: `** {0}... ({1})\n", CollectionName( CollectionManager.Current ),
CollectionManager.Current.Index );
sb.AppendFormat( "> **`Default Collection: `** {0}\n", CollectionManager.Default.AnonymizedName);
sb.AppendFormat( "> **`Current Collection: `** {0}\n", CollectionManager.Current.AnonymizedName);
foreach( var type in CollectionTypeExtensions.Special )
{
var collection = CollectionManager.ByType( type );
if( collection != null )
{
sb.AppendFormat( "> **`{0,-29}`** {1}... ({2})\n", type.ToName(), CollectionName( collection ), collection.Index );
sb.AppendFormat( "> **`{0,-29}`** {1}\n", type.ToName(), collection.AnonymizedName );
}
}
foreach( var (name, collection) in CollectionManager.Characters )
{
sb.AppendFormat( "> **`{2,-29}`** {0}... ({1})\n", CollectionName( collection ),
collection.Index, CharacterName( name ) );
sb.AppendFormat( "> **`{2,-29}`** {0}\n", collection.AnonymizedName, CharacterName( name ) );
}
foreach( var collection in CollectionManager.Where( c => c.HasCache ) )