Bladeren bron

Add ManualLogSource to Utility

habeebweeb 4 jaren geleden
bovenliggende
commit
0b8f791b5d

+ 3 - 3
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Constants.cs

@@ -554,7 +554,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 if (!MenuFileUtility.MenuFilesReady)
                 {
-                    Debug.Log("Menu files are not ready yet");
+                    Utility.Logger.LogInfo("Menu files are not ready yet");
                     return null;
                 }
             }
@@ -583,7 +583,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                         string iconFile = item.IconFile;
                         if (string.IsNullOrEmpty(iconFile) || !GameUty.FileSystem.IsExistentFile(iconFile))
                         {
-                            Debug.LogWarning($"Could not find icon '{iconFile}' for menu '{item.MenuFile}");
+                            Utility.Logger.LogWarning($"Could not find icon '{iconFile}' for menu '{item.MenuFile}");
                             return true;
                         }
                         else
@@ -600,7 +600,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                                 }
                                 catch
                                 {
-                                    Debug.LogWarning($"Could not load '{iconFile}' for menu '{item.MenuFile}");
+                                    Utility.Logger.LogWarning($"Could not load '{iconFile}' for menu '{item.MenuFile}");
                                     return true;
                                 }
                             }

+ 2 - 3
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/PropManager.cs

@@ -85,7 +85,6 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             GameObject dogu = MenuFileUtility.LoadModel(modItem);
             string name = modItem.Name;
             if (dogu != null) AttachDragPoint(dogu, name, new Vector3(0f, 0f, 0.5f));
-            // else Debug.Log($"Could not load mod item prop '{modItem.MenuFile}'");
         }
 
         public void SpawnMyRoomProp(MenuFileUtility.MyRoomItem item)
@@ -94,7 +93,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             GameObject dogu = GameObject.Instantiate(data.GetPrefab());
             string name = Translation.Get("myRoomPropNames", item.PrefabName);
             if (dogu != null) AttachDragPoint(dogu, name, new Vector3(0f, 0f, 0.5f));
-            else Debug.Log($"Could not load MyRoomCreative prop '{item.PrefabName}'");
+            else Utility.Logger.LogInfo($"Could not load MyRoomCreative prop '{item.PrefabName}'");
         }
 
         public void SpawnBG(string assetName)
@@ -235,7 +234,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
             else
             {
-                Debug.LogError($"Could not spawn object '{assetName}'");
+                Utility.Logger.LogError($"Could not spawn object '{assetName}'");
             }
         }
 

+ 1 - 2
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/MenuFileCache.cs

@@ -1,4 +1,3 @@
-using System;
 using System.IO;
 using System.Collections.Generic;
 
@@ -59,7 +58,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 if (binaryReader.ReadInt32() != cacheVersion)
                 {
-                    UnityEngine.Debug.Log($"Cache version out of date. Rebuilding");
+                    Utility.Logger.LogInfo($"Cache version out of date. Rebuilding");
                     return;
                 }
                 while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length)

+ 12 - 12
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/MenuFileUtility.cs

@@ -261,7 +261,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 }
                 else
                 {
-                    Debug.LogError("invalid model");
+                    Utility.Logger.LogError("invalid model");
                     return null;
                 }
             }
@@ -353,7 +353,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                     string text2 = binaryReader.ReadString();
                     if (!hashtable.ContainsKey(text2))
                     {
-                        Debug.LogError("nullbone= " + text2);
+                        Utility.Logger.LogError("nullbone= " + text2);
                     }
                     else
                     {
@@ -470,7 +470,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 {
                     if (fileStream == null || fileStream.Length == 0)
                     {
-                        Debug.LogError("Could not open mod menu");
+                        Utility.Logger.LogError("Could not open mod menu");
                         return null;
                     }
                     else
@@ -487,12 +487,12 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 if (afileBase == null || !afileBase.IsValid())
                 {
-                    Debug.LogError("Could not open menu");
+                    Utility.Logger.LogError("Could not open menu");
                     return null;
                 }
                 else if (afileBase.GetSize() == 0)
                 {
-                    Debug.LogError("Mod menu is empty");
+                    Utility.Logger.LogError("Mod menu is empty");
                     return null;
                 }
                 else
@@ -513,7 +513,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 }
                 catch
                 {
-                    Debug.LogError($"Could not load mesh for '{modItem.MenuFile}'");
+                    Utility.Logger.LogError($"Could not load mesh for '{modItem.MenuFile}'");
                 }
 
                 if (gameObject != null)
@@ -544,7 +544,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
             else
             {
-                Debug.LogWarning($"Could not parse menu file '{modItem.MenuFile}'");
+                Utility.Logger.LogWarning($"Could not parse menu file '{modItem.MenuFile}'");
                 return null;
             }
         }
@@ -579,7 +579,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
             catch
             {
-                Debug.LogError($"Could not read menu file '{menuFile}'");
+                Utility.Logger.LogError($"Could not read menu file '{menuFile}'");
                 return false;
             }
 
@@ -643,7 +643,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 }
                 catch (Exception e)
                 {
-                    Debug.LogWarning($"Could not parse menu file '{menuFile}' because {e.Message}");
+                    Utility.Logger.LogWarning($"Could not parse menu file '{menuFile}' because {e.Message}");
                     return false;
                 }
             }
@@ -662,7 +662,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                     if (fileStream == null) return false;
                     if (fileStream.Length == 0L)
                     {
-                        Debug.LogError($"Mod menu file '{modMenuFile}' is empty");
+                        Utility.Logger.LogError($"Mod menu file '{modMenuFile}' is empty");
                         return false;
                     }
                     buf = new byte[fileStream.Length];
@@ -671,7 +671,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
             catch (Exception e)
             {
-                Debug.LogError($"Could not read mod menu file '{modMenuFile} because {e.Message}'");
+                Utility.Logger.LogError($"Could not read mod menu file '{modMenuFile} because {e.Message}'");
                 return false;
             }
 
@@ -725,7 +725,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 }
                 catch (Exception e)
                 {
-                    Debug.LogWarning($"Could not parse mod menu file '{modMenuFile}' because {e}");
+                    Utility.Logger.LogWarning($"Could not parse mod menu file '{modMenuFile}' because {e}");
                     return false;
                 }
             }

+ 9 - 6
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Translation.cs

@@ -3,7 +3,6 @@ using System.Linq;
 using System.IO;
 using System.Collections.Generic;
 using Newtonsoft.Json.Linq;
-using UnityEngine;
 
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
@@ -28,8 +27,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             if (!Directory.Exists(currentTranslationPath))
             {
-                // Directory.CreateDirectory(currentTranslationPath);
-                Debug.LogWarning(
+                Utility.Logger.LogWarning(
                     $"No translations found for '{CurrentLanguage}' in '{currentTranslationPath}'"
                 );
                 return;
@@ -56,7 +54,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 }
                 catch
                 {
-                    Debug.LogError($"Could not find translation file '{translationFile}'");
+                    Utility.Logger.LogError($"Could not find translation file '{translationFile}'");
                 }
             }
         }
@@ -82,7 +80,10 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             if (!Translations.ContainsKey(category))
             {
-                if (warn) Debug.LogWarning($"Could not translate '{text}': category '{category}' was not found");
+                if (warn)
+                {
+                    Utility.Logger.LogWarning($"Could not translate '{text}': category '{category}' was not found");
+                }
                 return false;
             }
 
@@ -90,7 +91,9 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 if (warn)
                 {
-                    Debug.LogWarning($"Could not translate '{text}': '{text}' was not found in category '{category}'");
+                    Utility.Logger.LogWarning(
+                        $"Could not translate '{text}': '{text}' was not found in category '{category}'"
+                    );
                 }
                 return false;
             }

+ 2 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Utility.cs

@@ -1,6 +1,5 @@
 using System;
 using System.IO;
-using System.Collections.Generic;
 using System.Reflection;
 using UnityEngine;
 
@@ -8,6 +7,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 {
     internal static class Utility
     {
+        public static readonly BepInEx.Logging.ManualLogSource Logger
+            = BepInEx.Logging.Logger.CreateLogSource(MeidoPhotoStudio.pluginName);
         public enum ModKey
         {
             Control, Shift, Alt