Browse Source

Change Console.WriteLine -> Logger.LogWarning

habeebweeb 3 năm trước cách đây
mục cha
commit
5ee6cdc075
1 tập tin đã thay đổi với 13 bổ sung7 xóa
  1. 13 7
      src/MeidoPhotoStudio.Converter/Converters/MMConverter.cs

+ 13 - 7
src/MeidoPhotoStudio.Converter/Converters/MMConverter.cs

@@ -98,17 +98,23 @@ namespace MeidoPhotoStudio.Converter.Converters
             }
             catch (Exception e)
             {
-                Console.WriteLine($"Could not {(e is IOException ? "read" : "parse")} ini file {filePath}");
-                return null;
-            }
+                if (Plugin.Instance != null)
+                    Plugin.Instance.Logger.LogWarning(
+                        $"Could not {(e is IOException ? "read" : "parse")} ini file {filePath}"
+                    );
 
-            if (!iniFile.HasSection("scene"))
-            {
-                Console.WriteLine($"{filePath} is not a valid MM config because '[scene]' section is missing");
                 return null;
             }
 
-            return iniFile.GetSection("scene");
+            if (iniFile.HasSection("scene"))
+                return iniFile.GetSection("scene");
+
+            if (Plugin.Instance != null)
+                Plugin.Instance.Logger.LogWarning(
+                    $"{filePath} is not a valid MM config because '[scene]' section is missing"
+                );
+
+            return null;
         }
     }
 }