clean logging

This commit is contained in:
2024-12-25 11:00:25 +02:00
parent fbad383093
commit ac7c0352e5

View File

@@ -263,7 +263,10 @@ namespace VRCBoard
if (_atlasInfo == null) return null; if (_atlasInfo == null) return null;
if (!_atlasInfo.ContainsKey(imageId)) return null; if (!_atlasInfo.ContainsKey(imageId)) return null;
DataToken token = _atlasInfo[imageId]; DataToken token = _atlasInfo[imageId];
if (token.TokenType != TokenType.DataDictionary) return null; if (token.TokenType != TokenType.DataDictionary)
{
Debug.LogWarning("[_GetImageIdInfo] " + imageId + " does not exist.");
}
return token.DataDictionary; return token.DataDictionary;
} }
@@ -278,16 +281,17 @@ namespace VRCBoard
DataDictionary imageInfo = _GetImageIdInfo(imageId); DataDictionary imageInfo = _GetImageIdInfo(imageId);
if (imageInfo == null) if (imageInfo == null)
{ {
Debug.LogWarning("[_GetImageAtlasTexture] " + imageId + " not found!");
return false; return false;
} }
bool imageTypeSuccess = imageInfo.TryGetValue("type", out DataToken typeToken); bool imageTypeSuccess = imageInfo.TryGetValue("type", out DataToken typeToken);
bool uploadsSuccess = imageInfo.TryGetValue("uploads", out DataToken uploadsToken); bool uploadsSuccess = imageInfo.TryGetValue("uploads", out DataToken uploadsToken);
bool atlasSizeSuccess = imageInfo.TryGetValue("size", out DataToken sizeToken); bool atlasSizeSuccess = imageInfo.TryGetValue("size", out DataToken sizeToken);
//Debug.Log("Get image atlas texture " + imageId + " success: " + imageTypeSuccess + " " + uploadsSuccess + " " + atlasSizeSuccess);
if ((!imageTypeSuccess || !uploadsSuccess || !atlasSizeSuccess) || if ((!imageTypeSuccess || !uploadsSuccess || !atlasSizeSuccess) ||
(typeToken.TokenType != TokenType.String || uploadsToken.TokenType != TokenType.DataList || sizeToken.TokenType != TokenType.Double)) (typeToken.TokenType != TokenType.String || uploadsToken.TokenType != TokenType.DataList || sizeToken.TokenType != TokenType.Double))
{ {
Debug.LogWarning("[_GetImageAtlasTexture] " + imageId + " is not a valid atlas.");
return false; return false;
} }
@@ -362,6 +366,7 @@ namespace VRCBoard
} }
public void _RequestImageLoad(string imageId, string uploader, VRCBoardBaseComponent component) public void _RequestImageLoad(string imageId, string uploader, VRCBoardBaseComponent component)
{ {
if (uploader == null) uploader = "null";
//Debug.Log("Requesting image load " + imageId); //Debug.Log("Requesting image load " + imageId);
if (string.IsNullOrEmpty(imageId)) return; if (string.IsNullOrEmpty(imageId)) return;
string combinedId = $"{imageId}:{uploader}"; string combinedId = $"{imageId}:{uploader}";
@@ -374,6 +379,7 @@ namespace VRCBoard
if (split.Length != 2) return; if (split.Length != 2) return;
string imageId = split[0]; string imageId = split[0];
string uploader = split[1]; string uploader = split[1];
if (uploader == "null") uploader = null;
bool success = _GetImageAtlasTexture(imageId, uploader, out int atlasIndex, out Texture2D texture, bool success = _GetImageAtlasTexture(imageId, uploader, out int atlasIndex, out Texture2D texture,
out int position, out int size, out string type, out string hash); out int position, out int size, out string type, out string hash);
//Debug.Log("Try download image " + combinedImageId + " success: " + success); //Debug.Log("Try download image " + combinedImageId + " success: " + success);
@@ -384,7 +390,7 @@ namespace VRCBoard
private void OnSupporterInfoDownload(string data) private void OnSupporterInfoDownload(string data)
{ {
Debug.Log("Supporter info download success"); Debug.Log("[VRCBoard] Supporter info download success");
if (VRCJson.TryDeserializeFromJson(data, out DataToken result)) if (VRCJson.TryDeserializeFromJson(data, out DataToken result))
{ {
if (result.TokenType != TokenType.DataDictionary) return; if (result.TokenType != TokenType.DataDictionary) return;
@@ -394,7 +400,7 @@ namespace VRCBoard
} }
else else
{ {
Debug.LogError("Failed to deserialize supporter info"); Debug.LogError("[VRCBoard] Failed to deserialize supporter info");
} }
} }
private void SetSupporterInfo(DataDictionary value) private void SetSupporterInfo(DataDictionary value)
@@ -416,12 +422,12 @@ namespace VRCBoard
{ {
_perkNodes = perkToken.DataList; _perkNodes = perkToken.DataList;
} }
Debug.Log("Set supporter info "+vrcsuccess+" "+supporterSuccess+" "+perkSuccess); //Debug.Log("Set supporter info "+vrcsuccess+" "+supporterSuccess+" "+perkSuccess);
} }
private void OnCustomModuleDownload(int moduleIndex, string data) private void OnCustomModuleDownload(int moduleIndex, string data)
{ {
Debug.Log("Custom module download success " + moduleIndex); Debug.Log("[VRCBoard] Custom module download success " + moduleIndex);
if (VRCJson.TryDeserializeFromJson(data, out DataToken result)) if (VRCJson.TryDeserializeFromJson(data, out DataToken result))
{ {
if (result.TokenType != TokenType.DataDictionary) return; if (result.TokenType != TokenType.DataDictionary) return;
@@ -429,13 +435,13 @@ namespace VRCBoard
} }
else else
{ {
Debug.LogError("Failed to deserialize custom module " + moduleIndex); Debug.LogError("[VRCBoard] Failed to deserialize custom module " + moduleIndex);
} }
} }
private void OnCustomModuleUpdate(int moduleIndex, DataDictionary data) private void OnCustomModuleUpdate(int moduleIndex, DataDictionary data)
{ {
Debug.Log("Custom module update " + moduleIndex); Debug.Log("[VRCBoard] Custom module update " + moduleIndex);
foreach (var component in vrcBoardComponents) foreach (var component in vrcBoardComponents)
component._OnCustomModuleUpdate(moduleIndex, data); component._OnCustomModuleUpdate(moduleIndex, data);
} }
@@ -522,7 +528,7 @@ namespace VRCBoard
private void OnSupporterInfoUpdate() private void OnSupporterInfoUpdate()
{ {
Debug.Log("Supporter info updated"); Debug.Log("[VRCBoard] Supporter info updated");
foreach (var component in vrcBoardComponents) foreach (var component in vrcBoardComponents)
component._OnSupporterDataUpdate(); component._OnSupporterDataUpdate();
} }
@@ -538,7 +544,7 @@ namespace VRCBoard
} }
else else
{ {
Debug.LogError("Failed to deserialize atlas info"); Debug.LogError("[VRCBoard] Failed to deserialize atlas info");
} }
} }
@@ -582,13 +588,13 @@ namespace VRCBoard
public override void OnImageLoadSuccess(IVRCImageDownload result) public override void OnImageLoadSuccess(IVRCImageDownload result)
{ {
string url = result.Url.Get(); string url = result.Url.Get();
Debug.Log("Image load success " + url); Debug.Log("[VRCBoard] Image load success " + url);
Texture2D texture = result.Result; Texture2D texture = result.Result;
int index = GetAtlasIndexFromUrl(url); int index = GetAtlasIndexFromUrl(url);
if (index == -1) return; if (index == -1) return;
_downloadedAtlasTextures[index] = texture; _downloadedAtlasTextures[index] = texture;
_atlasDownloadTimes[index] = Time.time; _atlasDownloadTimes[index] = Time.time;
Debug.Log("Downloaded atlas texture " + index); Debug.Log("[VRCBoard] Downloaded atlas texture " + index);
foreach (var component in vrcBoardComponents) foreach (var component in vrcBoardComponents)
component._OnAtlasImageLoaded(index); component._OnAtlasImageLoaded(index);
} }
@@ -635,8 +641,7 @@ namespace VRCBoard
return textureCacheTextures[i]; return textureCacheTextures[i];
} }
} }
//Debug.LogWarning("[VRCBoard] Key not found: " + key);
Debug.LogWarning("Key not found: " + key);
return null; return null;
} }
@@ -690,7 +695,7 @@ namespace VRCBoard
startX = startX / size; startX = startX / size;
startY = startY / size; startY = startY / size;
Debug.Log("texture startX:" + startX + ", startY:" + startY); //Debug.Log("[VRCBoard] texture startX:" + startX + ", startY:" + startY);
int textureSize = 1024; int textureSize = 1024;