Example #1
0
 private void LogMessage(string message)
 {
     if (Log != null && message != null)
     {
         Log.WriteLine(message);
     }
     Debug.WriteLine(message);
     LogEventReceived?.Invoke(this, new LogEventArgs(message));
 }
Example #2
0
        public Task PurgeAndRecordLogEvent([FromBody] LogEventsModel logEvents)
        {
            var command = LogEventReceived.Purge(_context.DeviceId);

            if (logEvents != null)
            {
                command = LogEventReceived.HavingDetails(
                    _context.DeviceId,
                    logEvents,
                    purgeExisting: true);
            }

            return(_messagingSrv.SendAsync(command));
        }
Example #3
0
        public async Task When(LogEventReceived command)
        {
            // Create a new device log domain entity from received command.
            var deviceLog = DeviceLog.ForExistingDevice(command.DeviceId);

            foreach (LogEventModel model in command.LogEvents)
            {
                var logEvent = new ApplicationLog {
                    Type         = model.Type,
                    Message      = model.Content,
                    CreatedLocal = model.TimestampLocal,
                    CreatedUtc   = model.TimestampUtc
                };

                deviceLog.AddLog(logEvent);
            }

            // Save the device log and optionally delete any prior entries.
            using (_repoContext)
            {
                await _deviceRepository.WriteDeviceLog(deviceLog, command.PurgeExisting);
            }
        }
Example #4
0
        public Task RecordLogEvent([FromBody] LogEventsModel logEvents)
        {
            var command = LogEventReceived.HavingDetails(_context.DeviceId, logEvents);

            return(_messagingSrv.SendAsync(command));
        }