프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / KCOM / Logger.cs @ c7598c7d

이력 | 보기 | 이력해설 | 다운로드 (3.54 KB)

1 0f065e57 ljiyeon
using System;
2
using System.Collections.Generic;
3
using System.Diagnostics;
4
using System.IO;
5
using System.Linq;
6
using System.Text;
7
8
namespace KCOM
9
{
10
    class Logger
11
    {
12
13
        public static void sendReqLog(string name, string text, int Loglevel)
14
        {
15
            try
16
            {
17
                int lv = global::KCOM.Properties.Settings.Default.loglevel;
18
                if (lv >= Loglevel) //세팅의 로그 레벨보다 낮거나 같으면 남김
19
                {
20
                    // string Msg = (string)text + " / " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "\r\n";
21
                    string Msg = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "\t" + "REQ" + "\t" + name + "(" + (string)text + ")" + "\r\n";
22 af22332b ljiyeon
                    string Dir = "C:\\ProgramData\\MARKUS\\" + "Log";
23 0f065e57 ljiyeon
24
                    if (Directory.Exists(Dir) == false)
25
                    {
26
                        Directory.CreateDirectory(Dir);
27
                    }
28
29
                    int min = DateTime.Now.Minute / 1;
30
31
                    string path = Dir + "/" + "Log_" + DateTime.Now.ToString("yyyy-MM-dd HH-") + min + ".txt";
32
                    File.AppendAllText(path, Msg);
33
                }
34
            }
35
            catch (Exception e)
36
            {
37
                Debug.WriteLine(e);
38
            }
39
        }
40
41
        public static void sendResLog(string name, string text, int Loglevel)
42
        {
43
            try 
44
            {                
45
                int lv = global::KCOM.Properties.Settings.Default.loglevel;
46
                if (lv >= Loglevel) //세팅의 로그 레벨보다 낮거나 같으면 남김
47
                {
48
                    // string Msg = (string)text + " / " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "\r\n";
49
                    string Msg = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "\t" + "RES" + "\t" + name + "(" + (string)text + ")" + "\r\n";
50 af22332b ljiyeon
                    string Dir = "C:\\ProgramData\\MARKUS\\" + "Log";
51 0f065e57 ljiyeon
52
                    if (Directory.Exists(Dir) == false)
53
                    {
54
                        Directory.CreateDirectory(Dir);
55
                    }
56
57
                    int min = DateTime.Now.Minute / 1;
58
59
                    string path = Dir + "/" + "Log_" + DateTime.Now.ToString("yyyy-MM-dd HH-") + min + ".txt";
60
                    File.AppendAllText(path, Msg);
61
                }               
62
            }
63
            catch (Exception e)
64
            {
65
                Debug.WriteLine(e);
66
            }
67
        }
68 548c696e ljiyeon
69
        public static void sendCheckLog(string text, int Loglevel)
70
        {
71
            try
72
            {
73
                int lv = global::KCOM.Properties.Settings.Default.loglevel;
74
                if (lv >= Loglevel) //세팅의 로그 레벨보다 낮거나 같으면 남김
75
                {
76
                    // string Msg = (string)text + " / " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "\r\n";
77
                    string Msg = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "\t" + "RES" + "\t" + text + "\r\n";
78
                    string Dir = "C:\\ProgramData\\MARKUS\\" + "Check";
79
80
                    if (Directory.Exists(Dir) == false)
81
                    {
82
                        Directory.CreateDirectory(Dir);
83
                    }
84
85
                    int min = DateTime.Now.Minute / 1;
86
87
                    string path = Dir + "/" + "Log_" + DateTime.Now.ToString("yyyy-MM-dd HH-") + min + ".txt";
88
                    File.AppendAllText(path, Msg);
89
                }
90
            }
91
            catch (Exception e)
92
            {
93
                Debug.WriteLine(e);
94
            }
95
        }
96 0f065e57 ljiyeon
    }
97
}
클립보드 이미지 추가 (최대 크기: 500 MB)