프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDAutoModeling / Log.cs @ a79d6d46

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

1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.IO;
7

    
8
namespace SPPIDAutoModeling
9
{
10
    public static class Log
11
    {
12
        readonly static string defaultPath = Directory.GetCurrentDirectory() + @"\SPPID Converter.log";
13
        public static string Path = "";
14

    
15
        public static void WriteLine(Exception ex)
16
        {
17
            string logPath = Path;
18
            if (string.IsNullOrEmpty(Path))
19
            {
20
                logPath = defaultPath;
21
            }
22

    
23
            using (StreamWriter sw = new StreamWriter(logPath, true))
24
            {
25
                sw.WriteLine(ex.Message);
26
                sw.WriteLine(ex.StackTrace);
27
            }
28
        }
29

    
30
        public static void WriteLine(string text)
31
        {
32
            string logPath = Path;
33
            if (string.IsNullOrEmpty(Path))
34
            {
35
                logPath = defaultPath;
36
            }
37

    
38
            using (StreamWriter sw = new StreamWriter(logPath, true))
39
            {
40
                sw.WriteLine(text);
41
            }
42
        }
43
    }
44
}