Update Cryville.Common.Logging.

This commit is contained in:
2023-11-20 20:21:21 +08:00
parent e2c58c708f
commit c2e94afc1c
24 changed files with 280 additions and 140 deletions

View File

@@ -1,4 +1,3 @@
using Cryville.Common.Logging;
using Cryville.Crtr.Extension;
using Mono.Cecil;
using System;
@@ -36,7 +35,7 @@ namespace Cryville.Crtr.Browsing {
modules.Enqueue(new ModuleItem(extension.OpenRead()));
}
catch (Exception ex) {
Logger.Log("main", 4, "Extension", "Failed to load DLL {0}: {1}", extension, ex);
Game.MainLogger.Log(4, "Extension", "Failed to load DLL {0}: {1}", extension, ex);
}
}
}
@@ -68,10 +67,10 @@ namespace Cryville.Crtr.Browsing {
LoadExtension(type);
}
}
Logger.Log("main", 1, "Extension", "Loaded module {0}", module.Definition.Name);
Game.MainLogger.Log(1, "Extension", "Loaded module {0}", module.Definition.Name);
}
catch (Exception ex) {
Logger.Log("main", 4, "Extension", "An error occurred while trying to load module {0}: {1}", module.Definition.Name, ex);
Game.MainLogger.Log(4, "Extension", "An error occurred while trying to load module {0}: {1}", module.Definition.Name, ex);
}
finally {
module.Definition.Dispose();
@@ -89,7 +88,7 @@ namespace Cryville.Crtr.Browsing {
missingList.Add(reference.Name);
}
}
Logger.Log("main", 4, "Extension", "Could not load the module {0} because the following dependencies were missing: {1}", module.Definition.Name, missingList.Aggregate((current, next) => current + ", " + next));
Game.MainLogger.Log(4, "Extension", "Could not load the module {0} because the following dependencies were missing: {1}", module.Definition.Name, missingList.Aggregate((current, next) => current + ", " + next));
module.Definition.Dispose();
module.Stream.Dispose();
}
@@ -128,10 +127,10 @@ namespace Cryville.Crtr.Browsing {
if (name != null && path != null) _localRes.Add(name, path);
}
}
Logger.Log("main", 1, "Extension", "Loaded extension {0}", type);
Game.MainLogger.Log(1, "Extension", "Loaded extension {0}", type);
}
catch (Exception ex) {
Logger.Log("main", 4, "Extension", "Failed to load extension {0}: {1}", type, ex);
Game.MainLogger.Log(4, "Extension", "Failed to load extension {0}: {1}", type, ex);
}
}
}

View File

@@ -11,7 +11,6 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using Logger = Cryville.Common.Logging.Logger;
namespace Cryville.Crtr.Browsing {
internal class LegacyResourceManager : IPathedResourceManager<ChartDetail> {
@@ -41,7 +40,7 @@ namespace Cryville.Crtr.Browsing {
}
void OnFileWatcherError(object sender, ErrorEventArgs e) {
Logger.Log("main", 4, "Data", "An error occurred while watching file changes: {0}", e.GetException());
Game.MainLogger.Log(4, "Data", "An error occurred while watching file changes: {0}", e.GetException());
}
void OnFileChanged(object sender, FileSystemEventArgs e) {
@@ -235,13 +234,13 @@ namespace Cryville.Crtr.Browsing {
void LogAndPopup(int level, string format, params object[] args) {
var msg = string.Format(format, args);
Logger.Log("main", level, "Resource", msg);
Game.MainLogger.Log(level, "Resource", msg);
Popup.Create(msg);
}
void LogAndPopupExtra(int level, object extraLog, string format, params object[] args) {
var msg = string.Format(format, args);
Logger.Log("main", level, "Resource", "{0}\n{1}", msg, extraLog);
Game.MainLogger.Log(level, "Resource", "{0}\n{1}", msg, extraLog);
Popup.Create(msg);
}