Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stopping : being at the start of all log messages #606

Merged
merged 2 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Assets/Mirage/Runtime/LogFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public static class ILoggerExtensions
{
public static void LogError(this ILogger logger, object message)
{
logger.LogError(null, message);
logger.Log(LogType.Error, message);
}

public static void LogWarning(this ILogger logger, object message)
{
logger.LogWarning(null, message);
logger.Log(LogType.Warning, message);
}

public static bool LogEnabled(this ILogger logger) => logger.IsLogTypeAllowed(LogType.Log);
Expand Down
57 changes: 54 additions & 3 deletions Assets/Tests/Editor/LogFactoryTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NSubstitute;
using NSubstitute;
using NUnit.Framework;
using UnityEngine;

Expand Down Expand Up @@ -43,8 +43,59 @@ public void LogDebugFull()

ILogHandler mockHandler = Substitute.For<ILogHandler>();
logger.logHandler = mockHandler;
logger.Log("This message be logged");
mockHandler.Received().LogFormat(LogType.Log, null, "{0}", "This message be logged");
const string msg = "This message be logged";
logger.Log(msg);
mockHandler.Received().LogFormat(LogType.Log, null, "{0}", msg);
}

[Test]
public void LogWarningIgnore()
{
ILogger logger = LogFactory.GetLogger<LogFactoryTests>();
logger.filterLogType = LogType.Error;

ILogHandler mockHandler = Substitute.For<ILogHandler>();
logger.logHandler = mockHandler;
logger.LogWarning("This message should not be logged");
mockHandler.DidNotReceiveWithAnyArgs().LogFormat(default, null, null);
}

[Test]
public void LogWarningFull()
{
ILogger logger = LogFactory.GetLogger<LogFactoryTests>();
logger.filterLogType = LogType.Warning;

ILogHandler mockHandler = Substitute.For<ILogHandler>();
logger.logHandler = mockHandler;
const string msg = "This message be logged";
logger.LogWarning(msg);
mockHandler.Received().LogFormat(LogType.Warning, null, "{0}", msg);
}

[Test]
public void LogErrorIgnore()
{
ILogger logger = LogFactory.GetLogger<LogFactoryTests>();
logger.filterLogType = LogType.Exception;

ILogHandler mockHandler = Substitute.For<ILogHandler>();
logger.logHandler = mockHandler;
logger.LogError("This message should not be logged");
mockHandler.DidNotReceiveWithAnyArgs().LogFormat(default, null, null);
}

[Test]
public void LogErrorFull()
{
ILogger logger = LogFactory.GetLogger<LogFactoryTests>();
logger.filterLogType = LogType.Error;

ILogHandler mockHandler = Substitute.For<ILogHandler>();
logger.logHandler = mockHandler;
const string msg = "This message be logged";
logger.LogError(msg);
mockHandler.Received().LogFormat(LogType.Error, null, "{0}", msg);
}
}
}