Update
This commit is contained in:
53
Assets/D.A. Assets/DA-Shared/Runtime/Logging/DALogger.cs
Normal file
53
Assets/D.A. Assets/DA-Shared/Runtime/Logging/DALogger.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
|
||||
namespace DA_Assets.Logging
|
||||
{
|
||||
public static class DALogger
|
||||
{
|
||||
public static string violetColor = "#8b00ff";
|
||||
|
||||
public static void LogException(Exception ex)
|
||||
{
|
||||
UnityEngine.Debug.LogException(ex);
|
||||
}
|
||||
|
||||
public static void LogError(string log)
|
||||
{
|
||||
log = SubstringSafe(log, 15000);
|
||||
UnityEngine.Debug.LogError(log);
|
||||
}
|
||||
|
||||
public static void LogWarning(string log)
|
||||
{
|
||||
log = SubstringSafe(log, 15000);
|
||||
UnityEngine.Debug.LogWarning(log);
|
||||
}
|
||||
|
||||
public static void Log(string log)
|
||||
{
|
||||
log = SubstringSafe(log, 15000);
|
||||
UnityEngine.Debug.Log(log.TextBold());
|
||||
}
|
||||
|
||||
public static void LogSuccess(string log)
|
||||
{
|
||||
UnityEngine.Debug.Log(log.TextColor(violetColor).TextBold());
|
||||
}
|
||||
|
||||
public static string SubstringSafe(string value, int maxLength)
|
||||
{
|
||||
return value?.Length > maxLength ? value.Substring(0, maxLength) : value;
|
||||
}
|
||||
}
|
||||
|
||||
internal static class RichTextExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// <para><see href="https://forum.unity.com/threads/easy-text-format-your-debug-logs-rich-text-format.906464/"/></para>
|
||||
/// </summary>
|
||||
public static string TextBold(this string str) => "<b>" + str + "</b>";
|
||||
public static string TextColor(this string str, string clr) => string.Format("<color={0}>{1}</color>", clr, str);
|
||||
public static string TextItalic(this string str) => "<i>" + str + "</i>";
|
||||
public static string TextSize(this string str, int size) => string.Format("<size={0}>{1}</size>", size, str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f42c55b761c00446a0041d34fdb8dbe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user