-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathCommandLog.cs
59 lines (49 loc) · 1.32 KB
/
CommandLog.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System.Collections.Generic;
using UnityEngine;
namespace CommandTerminal
{
public enum TerminalLogType
{
Error = LogType.Error,
Assert = LogType.Assert,
Warning = LogType.Warning,
Message = LogType.Log,
Exception = LogType.Exception,
Input,
ShellMessage
}
public struct LogItem
{
public TerminalLogType type;
public string message;
public string stack_trace;
}
public class CommandLog
{
List<LogItem> logs = new List<LogItem>();
int max_items;
public List<LogItem> Logs {
get { return logs; }
}
public CommandLog(int max_items) {
this.max_items = max_items;
}
public void HandleLog(string message, TerminalLogType type) {
HandleLog(message, "", type);
}
public void HandleLog(string message, string stack_trace, TerminalLogType type) {
LogItem log = new LogItem() {
message = message,
stack_trace = stack_trace,
type = type
};
logs.Add(log);
if (logs.Count > max_items) {
logs.RemoveAt(0);
}
}
public void Clear() {
logs.Clear();
}
}
}