forked from KSP-KOS/KOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KSPLogger.cs
34 lines (31 loc) · 979 Bytes
/
KSPLogger.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace kOS
{
public class KSPLogger : Logger
{
public KSPLogger(SharedObjects shared) : base(shared)
{
}
public override void Log(string text)
{
base.Log(text);
UnityEngine.Debug.Log(text);
}
public override void Log(Exception e)
{
base.Log(e);
// print the call stack
UnityEngine.Debug.Log(e);
// print a fragment of the code where the exception ocurred
List<string> codeFragment = _shared.Cpu.GetCodeFragment(4);
StringBuilder messageBuilder = new StringBuilder();
messageBuilder.AppendLine("Code Fragment");
foreach (string instruction in codeFragment)
messageBuilder.AppendLine(instruction);
UnityEngine.Debug.Log(messageBuilder.ToString());
}
}
}