2020-05-27 06:04:19 +00:00
|
|
|
using System;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2020-06-03 00:17:33 +00:00
|
|
|
namespace ConformalDecals.Util {
|
2020-05-27 06:04:19 +00:00
|
|
|
public static class Logging {
|
2020-09-28 08:02:17 +00:00
|
|
|
public static void Log(string message) => Debug.Log("[ConformalDecals] " + message);
|
|
|
|
|
2020-05-27 06:04:19 +00:00
|
|
|
public static void Log(this PartModule module, string message) => Debug.Log(FormatMessage(module, message));
|
|
|
|
|
2020-09-28 08:02:17 +00:00
|
|
|
public static void LogWarning(string message) => Debug.LogWarning("[ConformalDecals] " + message);
|
|
|
|
|
|
|
|
public static void LogWarning(this PartModule module, string message) => Debug.LogWarning(FormatMessage(module, message));
|
|
|
|
|
|
|
|
public static void LogError(string message) => Debug.LogError("[ConformalDecals] " + message);
|
2020-05-27 06:04:19 +00:00
|
|
|
|
2020-09-28 08:02:17 +00:00
|
|
|
public static void LogError(this PartModule module, string message) => Debug.LogError(FormatMessage(module, message));
|
|
|
|
|
|
|
|
public static void LogException(string message, Exception exception) => Debug.LogException(new Exception("[ConformalDecals] " + message, exception));
|
2020-05-27 06:04:19 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|