-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDevLog.cs
More file actions
58 lines (46 loc) · 1.33 KB
/
Copy pathDevLog.cs
File metadata and controls
58 lines (46 loc) · 1.33 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
namespace BinaryPacketServer;
public enum LOG_LEVEL
{
TRACE,
DEBUG,
INFO,
WARN,
ERROR
}
public class DevLog
{
static System.Collections.Concurrent.ConcurrentQueue<string> logMsgQueue = new System.Collections.Concurrent.ConcurrentQueue<string>();
static LOG_LEVEL 출력가능_로그레벨 = new LOG_LEVEL();
static public void Init(LOG_LEVEL logLevel)
{
출력가능_로그레벨 = logLevel;
}
static public void ChangeLogLevel(LOG_LEVEL logLevel)
{
출력가능_로그레벨 = logLevel;
}
static public void Write(string msg, LOG_LEVEL logLevel = LOG_LEVEL.TRACE,
[CallerFilePath] string fileName = "",
[CallerMemberName] string methodName = "",
[CallerLineNumber] int lineNumber = 0)
{
if (출력가능_로그레벨 <= logLevel)
{
logMsgQueue.Enqueue(string.Format("{0}:{1}| {2}", DateTime.Now, methodName, msg));
}
}
static public bool GetLog(out string msg)
{
if (logMsgQueue.TryDequeue(out msg))
{
return true;
}
return false;
}
}