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 System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -15,7 +14,7 @@ namespace Cryville.Common.Font {
map1.Add(f.FullName, f);
}
else {
Logger.Log("main", 3, "UI", "Discarding a font with a duplicate full name {0}", f.FullName);
Shared.Logger.Log(3, "UI", "Discarding a font with a duplicate full name {0}", f.FullName);
continue;
}
List<Typeface> set2;

View File

@@ -1,4 +1,3 @@
using Cryville.Common.Logging;
using Cryville.Culture;
using System;
using System.Collections.Generic;
@@ -311,7 +310,7 @@ namespace Cryville.Common.Font {
bool flag = false;
while (_matcher.Match(lang, supported, out var match, out var distance)) {
if (distance > 40) break;
Logger.Log("main", 0, "UI", "Matching fonts for language {0}, distance = {1}", match, distance);
Shared.Logger.Log(0, "UI", "Matching fonts for language {0}, distance = {1}", match, distance);
if (match.Script.Equals(UltimateFallbackScript, StringComparison.OrdinalIgnoreCase)) {
flag = true;
}
@@ -322,7 +321,7 @@ namespace Cryville.Common.Font {
supported.Remove(match);
}
if (flag) yield break;
Logger.Log("main", 0, "UI", "Matching fallback fonts");
Shared.Logger.Log(0, "UI", "Matching fallback fonts");
foreach (var typeface in EnumerateTypefaces(MapScriptToTypefaces[UltimateFallbackScript], distinctFamily)) {
yield return typeface;
}

View File

@@ -1,4 +1,3 @@
using Cryville.Common.Logging;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
@@ -35,7 +34,7 @@ namespace Cryville.Common.Network.Http11 {
origPort = _baseUri.Port;
Headers = new Dictionary<string, string>();
_proxied = GetProxy(ref _directHost, ref _directPort);
Logger.Log("main", 0, "Network", "Connecting to {0}:{1}", DirectHost, DirectPort);
Shared.Logger.Log(0, "Network", "Connecting to {0}:{1}", DirectHost, DirectPort);
TcpClient = new TcpClient(DirectHost, DirectPort);
}
@@ -96,7 +95,7 @@ namespace Cryville.Common.Network.Http11 {
writer.Flush();
}
var response = new Http11Response(stream);
Logger.Log("main", 0, "Network", "{0}", response);
Shared.Logger.Log(0, "Network", "{0}", response);
return response;
}

View File

@@ -1,5 +1,4 @@
using Cryville.Common.Collections;
using Cryville.Common.Logging;
using Cryville.Common.Reflection;
using System;
using System.Collections.Generic;
@@ -203,7 +202,7 @@ namespace Cryville.Common.Pdt {
switch (GetIdentifier()) {
case "ver":
ws();
Logger.Log("main", 3, "PDT", "Legacy PDT directive #ver={0} found. Ignoring.", GetNumber());
Shared.Logger.Log(3, "PDT", "Legacy PDT directive #ver={0} found. Ignoring.", GetNumber());
break;
case "format":
ws();

View File

@@ -0,0 +1,7 @@
using Cryville.Common.Logging;
namespace Cryville.Common {
public static class Shared {
public static readonly Logger Logger = new Logger();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ef30832cb8f75dd4bb24744d068553f2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -8,7 +8,6 @@ using TMPro;
using UnityEngine;
using UnityEngine.TextCore.LowLevel;
using UnityEngine.TextCore.Text;
using Logger = Cryville.Common.Logging.Logger;
namespace Cryville.Common.Unity.UI {
[RequireComponent(typeof(TextMeshProUGUI))]
@@ -32,14 +31,14 @@ namespace Cryville.Common.Unity.UI {
else if (DefaultShader) ifont.material.shader = DefaultShader;
if (_font == null) {
_font = ifont;
Logger.Log("main", 1, "UI", "Using main font: {0}", typeface.FullName);
Shared.Logger.Log(1, "UI", "Using main font: {0}", typeface.FullName);
if (MaxFallbackCount <= 0) break;
}
else {
if (_font.fallbackFontAssetTable == null)
_font.fallbackFontAssetTable = new List<FontAsset>();
_font.fallbackFontAssetTable.Add(ifont);
Logger.Log("main", 1, "UI", "Using fallback font #{0}: {1}", _font.fallbackFontAssetTable.Count, typeface.FullName);
Shared.Logger.Log(1, "UI", "Using fallback font #{0}: {1}", _font.fallbackFontAssetTable.Count, typeface.FullName);
if (_font.fallbackFontAssetTable.Count >= MaxFallbackCount) break;
}
}