-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #330 from amazingalek/logging-overhaul
* New OWML config (available in OWML menu): Debug mode. * When Debug mode is enabled, *everything* is written to the console (in blue), including what was previously only written to log files and all Unity messages. * Deprecated Logger.Log and ModConsole.OwmlConsole, use ModHelper.Console instead.
- Loading branch information
Showing
22 changed files
with
148 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ public enum MessageType | |
|
||
Quit = 5, | ||
|
||
Fatal = 6 | ||
Fatal = 6, | ||
|
||
Debug = 7 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"gamePath": "C:/Program Files/Epic Games/OuterWilds", | ||
"debugMode": false, | ||
"combinationsBlockInput": false, | ||
"socketPort": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,43 @@ | ||
using System.Linq; | ||
using OWML.Common; | ||
using OWML.Common; | ||
using UnityEngine; | ||
|
||
namespace OWML.Logging | ||
{ | ||
public class UnityLogger : IUnityLogger | ||
{ | ||
private readonly LogType[] _relevantTypes = { | ||
LogType.Error, | ||
LogType.Exception | ||
}; | ||
|
||
private readonly IModSocket _socket; | ||
private readonly IApplicationHelper _appHelper; | ||
private readonly IModLogger _logger; | ||
private readonly IModConsole _console; | ||
private readonly IOwmlConfig _config; | ||
|
||
public UnityLogger(IModSocket socket, IApplicationHelper appHelper, IModLogger logger) | ||
public UnityLogger(IApplicationHelper appHelper, IModConsole console, IOwmlConfig config) | ||
{ | ||
_socket = socket; | ||
_appHelper = appHelper; | ||
_logger = logger; | ||
_console = console; | ||
_config = config; | ||
} | ||
|
||
public void Start() => | ||
public void Start() => | ||
_appHelper.AddLogCallback(OnLogMessageReceived); | ||
|
||
private void OnLogMessageReceived(string message, string stackTrace, LogType type) | ||
{ | ||
if (!_relevantTypes.Contains(type)) | ||
if (type != LogType.Error | ||
&& type != LogType.Exception | ||
&& !_config.DebugMode) | ||
{ | ||
return; | ||
} | ||
|
||
var line = $"{message}. Stack trace: {stackTrace?.Trim()}"; | ||
_logger.Log(line); | ||
_socket.WriteToSocket(new ModSocketMessage | ||
|
||
var messageType = type switch | ||
{ | ||
Type = MessageType.Error, | ||
Message = line, | ||
SenderName = "Unity", | ||
SenderType = type.ToString() | ||
}); | ||
LogType.Error => MessageType.Error, | ||
LogType.Exception => MessageType.Error, | ||
_ => MessageType.Debug | ||
}; | ||
|
||
_console.WriteLine(line, messageType, "Unity"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.