XDebug has Debug class and it will replace UnityEngine.Debug. The (X)Debug class will keep logs with these time and the tag.
You can import this asset from UnityPackage.
Log and the output are able to control with tag.
Default tag value is null and it is enabled.
You can switch the setting with Debug.NullIsEnableTag if you need.
EX:
Debug.EnableTag("TAG_A");
Debug.DisableTag("TAG_B");
Debug.Log("Message01", "TAG_A");
Debug.Log("Message02", "TAG_B");
Debug.LogWarning("Message03", this);RESULT:
Message01
Message03
Output format is able to customize with Debug.LogData.StringFormat.
This format is used as String.Format when the message will be generated.
Then, following KEYs are replaced with Debug.LogData field values.
| KEY | FIELD |
|---|---|
| {0} | Message |
| {1} | Context |
| {2} | Tag |
| {3} | LogType |
| {4} | Time in Time.sinceLevelLoad |
| {5} | Time in System.DateTime.Now |
EX:
Debug.LogData.StringFormat = "[{5}] {0}";
Debug.Log("MESSAGE04");RESULT:
[14:28:59] Message04
Some of these formats are able to set with the following settings.
Debug.LogData.StringFormatNullMessage = "";
Debug.LogData.StringFormatNullContext = "";
Debug.LogData.StringFormatNullTag = "";
Debug.LogData.StringFormatDateTimeNow = "HH:mm:ss";IEnumerable message such as Array, List and any others are separated into each item with Debug.LogData.StringFormatSeparator.
EX:
List<int> list = new List<int>() { "Message05", 6, 7 };
Debug.Log(list, "TAG_A");RESULT:
Message05, 6, 7
Logs are keeped in Debug.Logs upto Debug.MaxLogCount.
EX:
// Take null tagged logs with LINQ.
foreach (Debug.LogData log in Debug.Logs.Where<Debug.LogData>(log => log.tag == null))
{
Debug.Log(log);
}Debug.UnityLoggerEnabled equals UnityEngine.Debug.unitylogger.enabled..
When it gets false, no messages are output but the log will be kept in (X)Debug.Logs.
EX:
Debug.UnityLoggerEnabled = false;
Debug.Log("Message08");
Debug.UnityLoggerEnabled = true;
foreach (Debug.LogData log in Debug.Logs)
{
Debug.Log(log);
}RESULT:
~
Message08
"message" and "context" are keeped as string in Debug.LogData because "object message" and "Object context" are may be null.
In standard Unity editor, we can jump to the call-point of Debug.Log in source code with console click.
However if make a wrapper function of these, the call-point is set inside the wrapper.
Unfortunately, there are no way to solve this problem from any code. To avoid this problem, we have to make a ".dll".
This is the reason why assets directory doesn't include any source code of XDebug.