Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ErrorLog.cs « UVtools.WPF - github.com/sn4k3/UVtools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7e2f229a3e1c790d02d76afca0b7517ba3bddc14 (plain)
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
using System;
using System.Diagnostics;
using System.IO;

namespace UVtools.WPF
{
    public static class ErrorLog
    {
        private const string Filename = "errors.log";

        public static string FullPath = Path.Combine(UserSettings.SettingsFolder, Filename);

        public static void AppendLine(string errorType, string text)
        {
            try
            {
                File.AppendAllText(FullPath,
                    $"[v{App.VersionStr}] ({errorType}) @ {DateTime.Now}: {text}{Environment.NewLine}");
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
            }
        }

        public static StreamWriter GetStreamWriter()
        {
            return File.AppendText(FullPath);
        }
    }
}