-
Notifications
You must be signed in to change notification settings - Fork 172
/
Dbg.cs
78 lines (65 loc) · 1.48 KB
/
Dbg.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using UnityEngine;
using KBEngine;
using System;
using System.Collections;
using System.Collections.Generic;
namespace KBEngine
{
public enum DEBUGLEVEL : int
{
DEBUG = 0,
INFO,
WARNING,
ERROR,
NOLOG, // 放在最后面,使用这个时表示不输出任何日志(!!!慎用!!!)
}
public class Dbg
{
static public DEBUGLEVEL debugLevel = DEBUGLEVEL.DEBUG;
#if UNITY_EDITOR
static Dictionary<string, Profile> _profiles = new Dictionary<string, Profile>();
#endif
public static string getHead()
{
return "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff") + "] ";
}
public static void INFO_MSG(object s)
{
if (DEBUGLEVEL.INFO >= debugLevel)
Debug.Log(getHead() + s);
}
public static void DEBUG_MSG(object s)
{
if (DEBUGLEVEL.DEBUG >= debugLevel)
Debug.Log(getHead() + s);
}
public static void WARNING_MSG(object s)
{
if (DEBUGLEVEL.WARNING >= debugLevel)
Debug.LogWarning(getHead() + s);
}
public static void ERROR_MSG(object s)
{
if (DEBUGLEVEL.ERROR >= debugLevel)
Debug.LogError(getHead() + s);
}
public static void profileStart(string name)
{
#if UNITY_EDITOR
Profile p = null;
if(!_profiles.TryGetValue(name, out p))
{
p = new Profile(name);
_profiles.Add(name, p);
}
p.start();
#endif
}
public static void profileEnd(string name)
{
#if UNITY_EDITOR
_profiles[name].end();
#endif
}
}
}