Use custom logger everywhere.

This commit is contained in:
Ottermandias 2022-09-15 15:02:23 +02:00
parent fabbeeae13
commit 72ef666d51
87 changed files with 276 additions and 371 deletions

View file

@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Dalamud.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OtterGui;
using Penumbra.Mods;
using Penumbra.UI;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Penumbra.Collections;
@ -197,7 +196,7 @@ public partial class ModCollection
var defaultIdx = GetIndexForCollectionName( defaultName );
if( defaultIdx < 0 )
{
PluginLog.Error( $"Last choice of {ConfigWindow.DefaultCollection} {defaultName} is not available, reset to {Empty.Name}." );
Penumbra.Log.Error( $"Last choice of {ConfigWindow.DefaultCollection} {defaultName} is not available, reset to {Empty.Name}." );
Default = Empty;
configChanged = true;
}
@ -211,7 +210,7 @@ public partial class ModCollection
var currentIdx = GetIndexForCollectionName( currentName );
if( currentIdx < 0 )
{
PluginLog.Error( $"Last choice of {ConfigWindow.SelectedCollection} {currentName} is not available, reset to {DefaultCollection}." );
Penumbra.Log.Error( $"Last choice of {ConfigWindow.SelectedCollection} {currentName} is not available, reset to {DefaultCollection}." );
Current = DefaultName;
configChanged = true;
}
@ -229,7 +228,7 @@ public partial class ModCollection
var idx = GetIndexForCollectionName( typeName );
if( idx < 0 )
{
PluginLog.Error( $"Last choice of {type.ToName()} Collection {typeName} is not available, removed." );
Penumbra.Log.Error( $"Last choice of {type.ToName()} Collection {typeName} is not available, removed." );
configChanged = true;
}
else
@ -246,7 +245,7 @@ public partial class ModCollection
var idx = GetIndexForCollectionName( collectionName );
if( idx < 0 )
{
PluginLog.Error( $"Last choice of <{player}>'s Collection {collectionName} is not available, reset to {Empty.Name}." );
Penumbra.Log.Error( $"Last choice of <{player}>'s Collection {collectionName} is not available, reset to {Empty.Name}." );
_characters.Add( player, Empty );
configChanged = true;
}
@ -306,11 +305,11 @@ public partial class ModCollection
j.WriteEndObject();
j.WriteEndObject();
PluginLog.Verbose( "Active Collections saved." );
Penumbra.Log.Verbose( "Active Collections saved." );
}
catch( Exception e )
{
PluginLog.Error( $"Could not save active collections to file {file}:\n{e}" );
Penumbra.Log.Error( $"Could not save active collections to file {file}:\n{e}" );
}
}
@ -328,7 +327,7 @@ public partial class ModCollection
}
catch( Exception e )
{
PluginLog.Error( $"Could not read active collections from file {file}:\n{e}" );
Penumbra.Log.Error( $"Could not read active collections from file {file}:\n{e}" );
}
}

View file

@ -1,13 +1,12 @@
using OtterGui;
using OtterGui.Filesystem;
using Penumbra.Mods;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using Dalamud.Logging;
using OtterGui;
using OtterGui.Filesystem;
using Penumbra.Mods;
namespace Penumbra.Collections;
@ -107,7 +106,7 @@ public partial class ModCollection
{
if( !CanAddCollection( name, out var fixedName ) )
{
PluginLog.Warning( $"The new collection {name} would lead to the same path {fixedName} as one that already exists." );
Penumbra.Log.Warning( $"The new collection {name} would lead to the same path {fixedName} as one that already exists." );
return false;
}
@ -115,7 +114,7 @@ public partial class ModCollection
newCollection.Index = _collections.Count;
_collections.Add( newCollection );
newCollection.Save();
PluginLog.Debug( "Added collection {Name:l}.", newCollection.AnonymizedName );
Penumbra.Log.Debug( $"Added collection {newCollection.AnonymizedName}." );
CollectionChanged.Invoke( CollectionType.Inactive, null, newCollection );
SetCollection( newCollection.Index, CollectionType.Current );
return true;
@ -128,13 +127,13 @@ public partial class ModCollection
{
if( idx <= Empty.Index || idx >= _collections.Count )
{
PluginLog.Error( "Can not remove the empty collection." );
Penumbra.Log.Error( "Can not remove the empty collection." );
return false;
}
if( idx == DefaultName.Index )
{
PluginLog.Error( "Can not remove the default collection." );
Penumbra.Log.Error( "Can not remove the default collection." );
return false;
}
@ -179,7 +178,7 @@ public partial class ModCollection
}
}
PluginLog.Debug( "Removed collection {Name:l}.", collection.AnonymizedName );
Penumbra.Log.Debug( $"Removed collection {collection.AnonymizedName}." );
CollectionChanged.Invoke( CollectionType.Inactive, collection, null );
return true;
}
@ -335,12 +334,12 @@ public partial class ModCollection
if( !ByName( subCollectionName, out var subCollection ) )
{
changes = true;
PluginLog.Warning( $"Inherited collection {subCollectionName} for {collection.Name} does not exist, removed." );
Penumbra.Log.Warning( $"Inherited collection {subCollectionName} for {collection.Name} does not exist, removed." );
}
else if( !collection.AddInheritance( subCollection ) )
{
changes = true;
PluginLog.Warning( $"{collection.Name} can not inherit from {subCollectionName}, removed." );
Penumbra.Log.Warning( $"{collection.Name} can not inherit from {subCollectionName}, removed." );
}
}
@ -370,12 +369,12 @@ public partial class ModCollection
if( file.Name != $"{collection.Name.RemoveInvalidPathSymbols()}.json" )
{
PluginLog.Warning( $"Collection {file.Name} does not correspond to {collection.Name}." );
Penumbra.Log.Warning( $"Collection {file.Name} does not correspond to {collection.Name}." );
}
if( this[ collection.Name ] != null )
{
PluginLog.Warning( $"Duplicate collection found: {collection.Name} already exists." );
Penumbra.Log.Warning( $"Duplicate collection found: {collection.Name} already exists." );
}
else
{

View file

@ -1,6 +1,6 @@
using Penumbra.GameData.Enums;
using System;
using System.Linq;
using Penumbra.GameData.Enums;
namespace Penumbra.Collections;

View file

@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading;
using Dalamud.Logging;
using OtterGui.Classes;
using Penumbra.GameData.ByteString;
using Penumbra.Meta.Manager;
using Penumbra.Mods;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
namespace Penumbra.Collections;
@ -29,7 +27,7 @@ public partial class ModCollection
if( _cache == null )
{
CalculateEffectiveFileList();
PluginLog.Verbose( "Created new cache for collection {Name:l}.", Name );
Penumbra.Log.Verbose( $"Created new cache for collection {Name}." );
}
}
@ -61,7 +59,7 @@ public partial class ModCollection
{
_cache?.Dispose();
_cache = null;
PluginLog.Verbose( "Cleared cache of collection {Name:l}.", Name );
Penumbra.Log.Verbose( $"Cleared cache of collection {Name}." );
}
public IEnumerable< Utf8GamePath > ReverseResolvePath( FullPath path )
@ -87,7 +85,7 @@ public partial class ModCollection
return true;
}
PluginLog.Error( $"The redirected path is too long to add the redirection\n\t{path}\n\t--> {fullPath}" );
Penumbra.Log.Error( $"The redirected path is too long to add the redirection\n\t{path}\n\t--> {fullPath}" );
return false;
}
@ -125,13 +123,11 @@ public partial class ModCollection
return;
}
PluginLog.Debug( "[{Thread}] Recalculating effective file list for {CollectionName:l}",
Thread.CurrentThread.ManagedThreadId, AnonymizedName );
Penumbra.Log.Debug( $"[{Thread.CurrentThread.ManagedThreadId}] Recalculating effective file list for {AnonymizedName}" );
_cache ??= new Cache( this );
_cache.FullRecalculation();
PluginLog.Debug( "[{Thread}] Recalculation of effective file list for {CollectionName:l} finished.",
Thread.CurrentThread.ManagedThreadId, AnonymizedName );
Penumbra.Log.Debug( $"[{Thread.CurrentThread.ManagedThreadId}] Recalculation of effective file list for {AnonymizedName} finished." );
}
// Set Metadata files.
@ -204,7 +200,7 @@ public partial class ModCollection
else
{
_cache.MetaManipulations.SetFiles();
PluginLog.Debug( "Set CharacterUtility resources for collection {Name:l}.", Name );
Penumbra.Log.Debug( $"Set CharacterUtility resources for collection {Name}." );
}
}
}

View file

@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Dalamud.Logging;
using OtterGui;
using OtterGui.Classes;
using Penumbra.GameData.ByteString;
using Penumbra.Meta.Manager;
using Penumbra.Meta.Manipulations;
using Penumbra.Mods;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Penumbra.Collections;
@ -496,7 +495,7 @@ public partial class ModCollection
}
catch( Exception e )
{
PluginLog.Error( $"Unknown Error:\n{e}" );
Penumbra.Log.Error( $"Unknown Error:\n{e}" );
}
}
}

View file

@ -1,7 +1,7 @@
using Penumbra.Mods;
using System;
using System.Collections.Generic;
using System.Linq;
using Penumbra.Mods;
namespace Penumbra.Collections;

View file

@ -1,13 +1,12 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OtterGui.Filesystem;
using Penumbra.Mods;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Dalamud.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OtterGui.Filesystem;
using Penumbra.Mods;
namespace Penumbra.Collections;
@ -67,7 +66,7 @@ public partial class ModCollection
}
catch( Exception e )
{
PluginLog.Error( $"Could not save collection {AnonymizedName}:\n{e}" );
Penumbra.Log.Error( $"Could not save collection {AnonymizedName}:\n{e}" );
}
}
@ -90,11 +89,11 @@ public partial class ModCollection
try
{
file.Delete();
PluginLog.Information( "Deleted collection file for {Name:l}.", AnonymizedName );
Penumbra.Log.Information( $"Deleted collection file for {AnonymizedName}." );
}
catch( Exception e )
{
PluginLog.Error( $"Could not delete collection file for {AnonymizedName}:\n{e}" );
Penumbra.Log.Error( $"Could not delete collection file for {AnonymizedName}:\n{e}" );
}
}
@ -105,7 +104,7 @@ public partial class ModCollection
inheritance = Array.Empty< string >();
if( !file.Exists )
{
PluginLog.Error( $"Could not read collection because file does not exist." );
Penumbra.Log.Error( "Could not read collection because file does not exist." );
return null;
}
@ -123,7 +122,7 @@ public partial class ModCollection
}
catch( Exception e )
{
PluginLog.Error( $"Could not read collection information from file:\n{e}" );
Penumbra.Log.Error( $"Could not read collection information from file:\n{e}" );
}
return null;

View file

@ -1,9 +1,8 @@
using OtterGui.Filesystem;
using Penumbra.Mods;
using System;
using System.Collections.Generic;
using System.Linq;
using Dalamud.Logging;
using OtterGui.Filesystem;
using Penumbra.Mods;
namespace Penumbra.Collections;
@ -81,7 +80,7 @@ public partial class ModCollection
collection.ModSettingChanged += OnInheritedModSettingChange;
collection.InheritanceChanged += OnInheritedInheritanceChange;
InheritanceChanged.Invoke( false );
PluginLog.Debug( "Added {InheritedName:l} to {Name:l} inheritances.", collection.AnonymizedName, AnonymizedName );
Penumbra.Log.Debug( $"Added {collection.AnonymizedName} to {AnonymizedName} inheritances." );
return true;
}
@ -91,7 +90,7 @@ public partial class ModCollection
ClearSubscriptions( inheritance );
_inheritance.RemoveAt( idx );
InheritanceChanged.Invoke( false );
PluginLog.Debug( "Removed {InheritedName:l} from {Name:l} inheritances.", inheritance.AnonymizedName, AnonymizedName );
Penumbra.Log.Debug( $"Removed {inheritance.AnonymizedName} from {AnonymizedName} inheritances." );
}
private void ClearSubscriptions( ModCollection other )
@ -106,7 +105,7 @@ public partial class ModCollection
if( _inheritance.Move( from, to ) )
{
InheritanceChanged.Invoke( false );
PluginLog.Debug( "Moved {Name:l}s inheritance {From} to {To}.", AnonymizedName, from, to );
Penumbra.Log.Debug( $"Moved {AnonymizedName}s inheritance {from} to {to}." );
}
}
@ -122,7 +121,7 @@ public partial class ModCollection
default:
if( modIdx < 0 || modIdx >= _settings.Count )
{
PluginLog.Warning(
Penumbra.Log.Warning(
$"Collection state broken, Mod {modIdx} in inheritance does not exist. ({_settings.Count} mods exist)." );
return;
}

View file

@ -1,6 +1,6 @@
using Penumbra.Mods;
using System.Collections.Generic;
using System.Linq;
using Penumbra.Mods;
namespace Penumbra.Collections;

View file

@ -1,8 +1,8 @@
using OtterGui.Filesystem;
using Penumbra.Mods;
using System;
using System.Collections.Generic;
using System.Linq;
using OtterGui.Filesystem;
using Penumbra.Mods;
namespace Penumbra.Collections;