aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Telemetry/Mappers/LogMapper.cs
blob: 6f5abbf1b7be9b2bf6f654f431662e05bb5af222 (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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Logging;
using Tango.PMR.Debugging;
using Tango.Telemetry.Telemetries;

namespace Tango.Telemetry.Mappers
{
    public class LogMapper
    {
        public static TelemetryLog MapLog(LogItemBase log)
        {
            TelemetryLog tLog = new TelemetryLog();
            tLog.Source = "Application";
            tLog.Time = DateTime.UtcNow;
            tLog.Category = log.Category.ToString();
            tLog.Class = log.ClassName;
            tLog.Method = log.CallerMethodName;
            tLog.Line = log.CallerLineNumber;
            tLog.Message = log.Message;

            return tLog;
        }

        public static TelemetryLog MapLog(StartDebugLogResponse log)
        {
            TelemetryLog tLog = new TelemetryLog();
            tLog.Source = "Firmware";
            tLog.Time = DateTime.UtcNow;
            tLog.Category = log.Category.ToString();
            tLog.Class = log.FileName;
            tLog.Method = $"[{log.ModuleId}] [{log.Filter}] [{log.Parameter}]";
            tLog.Line = log.LineNumber;
            tLog.Message = log.Message;

            return tLog;
        }
    }
}