aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Helpers/Log.cs
blob: 64391cd1ecabbbefdb722ca12501706946629a84 (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
using System.Collections.Generic;
using System.Text;

namespace Timeline.Helpers
{
    // TODO! Remember to remove this after refactor.
    public static class MyLogHelper
    {
        public static KeyValuePair<string, object> Pair(string key, object value) => new KeyValuePair<string, object>(key, value);

        public static string FormatLogMessage(string summary, params KeyValuePair<string, object>[] properties)
        {
            var builder = new StringBuilder();
            builder.Append(summary);
            foreach (var property in properties)
            {
                builder.AppendLine();
                builder.Append(property.Key);
                builder.Append(" : ");
                builder.Append(property.Value);
            }
            return builder.ToString();
        }
    }

    public static class Log
    {
        public static string Format(string summary, params (string, object)[] properties)
        {
            var builder = new StringBuilder();
            builder.Append(summary);
            foreach (var property in properties)
            {
                var (key, value) = property;
                builder.AppendLine();
                builder.Append(key);
                builder.Append(" : ");
                builder.Append(value);
            }
            return builder.ToString();
        }
    }
}