Skip to content

Commit

Permalink
ModLogger -> PrefixLogger
Browse files Browse the repository at this point in the history
Explains what it does better
  • Loading branch information
blowfishpro committed May 1, 2019
1 parent 0a2c842 commit a8bcad2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
Expand Up @@ -2,12 +2,12 @@

namespace ModuleManager.Logging
{
public class ModLogger : IBasicLogger
public class PrefixLogger : IBasicLogger
{
private readonly string prefix;
private readonly IBasicLogger logger;

public ModLogger(string prefix, IBasicLogger logger)
public PrefixLogger(string prefix, IBasicLogger logger)
{
if (string.IsNullOrEmpty(prefix)) throw new ArgumentNullException(nameof(prefix));
this.prefix = $"[{prefix}] ";
Expand Down
4 changes: 2 additions & 2 deletions ModuleManager/ModuleManager.cs
Expand Up @@ -132,7 +132,7 @@ internal void Awake()
Log(string.Format("Adding post patch to the loading screen {0}", list.Count));
list.Insert(gameDatabaseIndex + 1, aGameObject.AddComponent<PostPatchLoader>());

patchRunner = new MMPatchRunner(new ModLogger("ModuleManager", new UnityLogger(Debug.unityLogger)));
patchRunner = new MMPatchRunner(new PrefixLogger("ModuleManager", new UnityLogger(Debug.unityLogger)));
StartCoroutine(patchRunner.Run());

// Workaround for 1.6.0 Editor bug after a PartDatabase rebuild.
Expand Down Expand Up @@ -314,7 +314,7 @@ private IEnumerator DataBaseReloadWithMM(bool dump = false)
QualitySettings.vSyncCount = 0;
Application.targetFrameRate = -1;

patchRunner = new MMPatchRunner(new ModLogger("ModuleManager", new UnityLogger(Debug.unityLogger)));
patchRunner = new MMPatchRunner(new PrefixLogger("ModuleManager", new UnityLogger(Debug.unityLogger)));

float totalLoadWeight = GameDatabase.Instance.LoadWeight() + PartLoader.Instance.LoadWeight();
bool startedReload = false;
Expand Down
2 changes: 1 addition & 1 deletion ModuleManager/ModuleManager.csproj
Expand Up @@ -51,7 +51,7 @@
<Compile Include="Logging\IBasicLogger.cs" />
<Compile Include="Logging\ILogMessage.cs" />
<Compile Include="Logging\LogSplitter.cs" />
<Compile Include="Logging\ModLogger.cs" />
<Compile Include="Logging\PrefixLogger.cs" />
<Compile Include="Logging\LogMessage.cs" />
<Compile Include="Logging\QueueLogger.cs" />
<Compile Include="Logging\QueueLogRunner.cs" />
Expand Down
2 changes: 1 addition & 1 deletion ModuleManager/PostPatchLoader.cs
Expand Up @@ -22,7 +22,7 @@ public class PostPatchLoader : LoadingSystem

private static readonly List<ModuleManagerPostPatchCallback> postPatchCallbacks = new List<ModuleManagerPostPatchCallback>();

private readonly IBasicLogger logger = new ModLogger("ModuleManager", new UnityLogger(UnityEngine.Debug.unityLogger));
private readonly IBasicLogger logger = new PrefixLogger("ModuleManager", new UnityLogger(UnityEngine.Debug.unityLogger));

private bool ready = false;

Expand Down
Expand Up @@ -6,23 +6,23 @@

namespace ModuleManagerTests.Logging
{
public class ModLoggerTest
public class PrefixLoggerTest
{
private IBasicLogger innerLogger;
private ModLogger logger;
private PrefixLogger logger;

public ModLoggerTest()
public PrefixLoggerTest()
{
innerLogger = Substitute.For<IBasicLogger>();
logger = new ModLogger("MyMod", innerLogger);
logger = new PrefixLogger("MyMod", innerLogger);
}

[Fact]
public void TestConstructor__PrefixNull()
{
ArgumentNullException e = Assert.Throws<ArgumentNullException>(delegate
{
new ModLogger(null, innerLogger);
new PrefixLogger(null, innerLogger);
});

Assert.Equal("prefix", e.ParamName);
Expand All @@ -33,7 +33,7 @@ public void TestConstructor__PrefixBlank()
{
ArgumentNullException e = Assert.Throws<ArgumentNullException>(delegate
{
new ModLogger("", innerLogger);
new PrefixLogger("", innerLogger);
});

Assert.Equal("prefix", e.ParamName);
Expand All @@ -44,7 +44,7 @@ public void TestConstructor__LoggerNull()
{
ArgumentNullException e = Assert.Throws<ArgumentNullException>(delegate
{
new ModLogger("blah", null);
new PrefixLogger("blah", null);
});

Assert.Equal("logger", e.ParamName);
Expand Down
2 changes: 1 addition & 1 deletion ModuleManagerTests/ModuleManagerTests.csproj
Expand Up @@ -116,7 +116,7 @@
<Compile Include="DummyTest.cs" />
<Compile Include="Extensions\ConfigNodeExtensionsTest.cs" />
<Compile Include="Extensions\NodeStackExtensionsTest.cs" />
<Compile Include="Logging\ModLoggerTest.cs" />
<Compile Include="Logging\PrefixLoggerTest.cs" />
<Compile Include="PatchExtractorTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Progress\PatchProgressTest.cs" />
Expand Down

0 comments on commit a8bcad2

Please sign in to comment.