aboutsummaryrefslogtreecommitdiff
path: root/Tools/Hazel-Networking/Hazel.UnitTests/TestLogger.cs
blob: 01ca8931488ea9d1961af752378545cca594c9eb (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
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hazel.UnitTests
{
    public class TestLogger : ILogger
    {
        private readonly string prefix;

        public TestLogger(string prefix = "")
        {
            this.prefix = prefix;
        }

        public void WriteVerbose(string msg)
        {
            if (string.IsNullOrEmpty(this.prefix))
            {
                Console.WriteLine($"[VERBOSE] {msg}");
            }
            else
            {
                Console.WriteLine($"[{this.prefix}][VERBOSE] {msg}");
            }
        }

        public void WriteWarning(string msg)
        {
            if (string.IsNullOrEmpty(this.prefix))
            {
                Console.WriteLine($"[WARN] {msg}");
            }
            else
            {
                Console.WriteLine($"[{this.prefix}][WARN] {msg}");
            }
        }

        public void WriteError(string msg)
        {
            if (string.IsNullOrEmpty(this.prefix))
            {
                Console.WriteLine($"[ERROR] {msg}");
            }
            else
            {
                Console.WriteLine($"[{this.prefix}][ERROR] {msg}");
            }
        }

        public void WriteInfo(string msg)
        {
            if (string.IsNullOrEmpty(this.prefix))
            {
                Console.WriteLine($"[INFO] {msg}");
            }
            else
            {
                Console.WriteLine($"[{this.prefix}][INFO] {msg}");
            }
        }
    }
}