mirror of
https://github.com/PorktoberRevolution/ReStocked
synced 2024-09-01 17:34:42 +00:00
Unify logging
And add helpful tags to everything
This commit is contained in:
parent
ddb79541f5
commit
a453ed89eb
@ -31,7 +31,7 @@ namespace Restock
|
||||
|
||||
if (string.IsNullOrEmpty(serializedNode))
|
||||
{
|
||||
Debug.LogError("Serialized node is null or empty!");
|
||||
this.LogError("Serialized node is null or empty!");
|
||||
yield break;
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ namespace Restock
|
||||
|
||||
if (fairingModule == null)
|
||||
{
|
||||
Debug.LogError("No fairing module found on part!");
|
||||
this.LogError("No fairing module found on part!");
|
||||
yield break;
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ namespace Restock
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogException(new Exception($"[{nameof(ModuleRestockModifyFairingMaterials)}] cannot parse node as material modifier: \n{node2.ToString()}\n", ex));
|
||||
this.LogException($"cannot parse node as material modifier: \n{node2.ToString()}\n", ex);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace Restock
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"Can't find shader {newShaderName}");
|
||||
this.LogError($"Can't find shader {newShaderName}");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ namespace Restock
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogException(new Exception($"[{nameof(ModuleRestockModifyMaterials)}] cannot parse node as material modifier: \n{node3.ToString()}\n", ex));
|
||||
this.LogException($"cannot parse node as material modifier: \n{node3.ToString()}\n", ex);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ namespace Restock
|
||||
|
||||
if (modelTransforms.Length == 0)
|
||||
{
|
||||
Debug.LogError($"Couldn't find transform named '{value.name}' on part");
|
||||
this.LogError($"Couldn't find transform named '{value.name}' on part");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ namespace Restock
|
||||
Renderer renderer = transform.GetComponent<Renderer>();
|
||||
|
||||
if (renderer == null)
|
||||
Debug.LogError($"No renderer found on transform '{transform.name}'");
|
||||
this.LogError($"No renderer found on transform '{transform.name}'");
|
||||
else
|
||||
transformRenderers.Add(renderer);
|
||||
}
|
||||
@ -98,7 +98,7 @@ namespace Restock
|
||||
|
||||
if (modelTransforms.Length == 0)
|
||||
{
|
||||
Debug.LogError($"Couldn't find transform named '{value.name}' on part");
|
||||
this.LogError($"Couldn't find transform named '{value.name}' on part");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ namespace Restock
|
||||
Renderer[] transformRenderers = transform.GetComponentsInChildren<Renderer>();
|
||||
|
||||
if (transformRenderers.Length == 0)
|
||||
Debug.LogError($"No renderers found on transform '{transform.name}' or its children");
|
||||
this.LogError($"No renderers found on transform '{transform.name}' or its children");
|
||||
else
|
||||
renderers.Concat(transform.GetComponentsInChildren<Renderer>());
|
||||
}
|
||||
@ -121,7 +121,7 @@ namespace Restock
|
||||
Transform modelTransform = part.partTransform.Find("model");
|
||||
|
||||
if (modelTransform == null)
|
||||
Debug.LogError("Couldn't find model transform");
|
||||
this.LogError("Couldn't find model transform");
|
||||
else
|
||||
renderers = modelTransform.GetComponentsInChildren<Renderer>();
|
||||
}
|
||||
|
16
Source/Restock/PartModuleExtensions.cs
Normal file
16
Source/Restock/PartModuleExtensions.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Restock
|
||||
{
|
||||
public static class PartModuleExtensions
|
||||
{
|
||||
public static void Log(this PartModule module, string message) => Debug.Log(FormatMessage(module, message));
|
||||
public static void LogWarning(this PartModule module, string message) => Debug.LogWarning(FormatMessage(module, message));
|
||||
public static void LogError(this PartModule module, string message) => Debug.LogError(FormatMessage(module, message));
|
||||
public static void LogException(this PartModule module, string message, Exception exception) => Debug.LogException(new Exception(FormatMessage(module, message), exception));
|
||||
|
||||
private static string FormatMessage(PartModule module, string message) => $"[{GetPartName(module.part)} {module.GetType()}] {message}";
|
||||
private static string GetPartName(Part part) => part.partInfo?.name ?? part.name;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user