aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Tango.FSE.UI/Logging/DefaultLoggingProvider.cs
blob: 56ec08cbd1efbeaf1bf53ca891d15572c2fbc4db (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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.FSE.Common.Connection;
using Tango.FSE.Common.Logging;
using Tango.Integration.ExternalBridge;
using Tango.Integration.Logging;
using Tango.Logging;

namespace Tango.FSE.UI.Logging
{
    public class DefaultLoggingProvider : ILoggingProvider
    {
        public event EventHandler<LogItemBase> ApplicationLogAvailable;
        public event EventHandler<EmbeddedLogItem> EmbeddedLogAvailable;

        public DefaultLoggingProvider(IMachineProvider machineProvider)
        {
            if (machineProvider.MachineOperator is ExternalBridgeTcpClient)
            {
                (machineProvider.MachineOperator as ExternalBridgeTcpClient).ApplicationLogAvailable += DefaultLoggingProvider_ApplicationLogAvailable;
            }

            machineProvider.MachineOperator.DebugLogAvailable += MachineOperator_DebugLogAvailable;
        }

        private void DefaultLoggingProvider_ApplicationLogAvailable(object sender, LogItemBase log)
        {
            ApplicationLogAvailable?.Invoke(this, log);
        }

        private void MachineOperator_DebugLogAvailable(object sender, PMR.Debugging.StartDebugLogResponse log)
        {
            EmbeddedLogAvailable?.Invoke(this, new EmbeddedLogItem(log) {  TimeStamp = DateTime.Now});
        }
    }
}