public void SeriLogPublisher_NewPublisher_Reading_LogData_From_Elasticsearch_Success() { //-------------------------Arrange------------------------------ var dependency = new Depends(Depends.ContainerType.AnonymousElasticsearch); var hostName = "http://" + dependency.Container.IP; var loggerSource = new SerilogElasticsearchSource { Port = DefaultPort, HostName = hostName, SearchIndex = "warewolftestlogs" }; var uri = new Uri(hostName + ":" + DefaultPort); var logger = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.Sink(new ElasticsearchSink(new ElasticsearchSinkOptions(uri) { AutoRegisterTemplate = true, IndexDecider = (e, o) => loggerSource.SearchIndex, })) .CreateLogger(); var mockSeriLogConfig = new Mock <ISeriLogConfig>(); mockSeriLogConfig.SetupGet(o => o.Logger).Returns(logger); var executionID = Guid.NewGuid(); using (var loggerConnection = loggerSource.NewConnection(mockSeriLogConfig.Object)) { var loggerPublisher = loggerConnection.NewPublisher(); var mockDataObject = SetupDataObjectWithAssignedInputs(executionID); var auditLog = new Audit(mockDataObject.Object, "LogAdditionalDetail", "Test", null, null); var logEntryCommand = new AuditCommand { Audit = auditLog, Type = "LogEntry" }; //-------------------------Act---------------------------------- loggerPublisher.Info(GlobalConstants.WarewolfLogsTemplate, logEntryCommand); } Task.Delay(500).Wait(); //-------------------------Assert------------------------------------ var dataFromDb = new TestElasticsearchDatabase(); var dataList = dataFromDb.GetPublishedData(loggerSource, executionID.ToString()).ToList(); Assert.AreEqual(1, dataList.Count); foreach (Dictionary <string, object> fields in dataList) { var level = fields.Where(pair => pair.Key.Contains("level")).Select(pair => pair.Value).FirstOrDefault(); Assert.AreEqual("Information", level.ToString()); var messageTemplate = fields.Where(pair => pair.Key.Contains("messageTemplate")).Select(pair => pair.Value).FirstOrDefault(); Assert.AreEqual("{@Data}", messageTemplate.ToString()); var message = fields.Where(pair => pair.Key.Contains("message")); Assert.IsNotNull(message); } }
public void LogActivityExecuteState(object nextActivityObject) { var auditLog = new Audit(_dsfDataObject, "LogActivityExecuteState", null, null, nextActivityObject); LogAuditState(auditLog); }
private void LogAuditState(Audit auditLog) { _logWriter.LogAuditState(auditLog); }
public void LogStopExecutionState(object activity) { var auditLog = new Audit(_dsfDataObject, "LogStopExecutionState", null, activity, null); LogAuditState(auditLog); }
public void LogExecuteException(Exception exception, object activity) { var auditLog = new Audit(_dsfDataObject, "LogExecuteException", exception.Message, activity, null, exception); LogAuditState(auditLog); }
public void LogExecuteCompleteState(object activity) { var auditLog = new Audit(_dsfDataObject, "LogExecuteCompleteState", null, activity, null); LogAuditState(auditLog); }
public void LogPreExecuteState(IDev2Activity nextActivity) { var auditLog = new Audit(_dsfDataObject, "LogPreExecuteState", null, null, nextActivity); LogAuditState(auditLog); }
public void LogPostExecuteState(IDev2Activity previousActivity, IDev2Activity nextActivity) { var auditLog = new Audit(_dsfDataObject, "LogPostExecuteState", null, previousActivity, nextActivity); LogAuditState(auditLog); }