Exemple #1
0
        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);
            }
        }
Exemple #2
0
        public void LogActivityExecuteState(object nextActivityObject)
        {
            var auditLog = new Audit(_dsfDataObject, "LogActivityExecuteState", null, null, nextActivityObject);

            LogAuditState(auditLog);
        }
Exemple #3
0
 private void LogAuditState(Audit auditLog)
 {
     _logWriter.LogAuditState(auditLog);
 }
Exemple #4
0
        public void LogStopExecutionState(object activity)
        {
            var auditLog = new Audit(_dsfDataObject, "LogStopExecutionState", null, activity, null);

            LogAuditState(auditLog);
        }
Exemple #5
0
        public void LogExecuteException(Exception exception, object activity)
        {
            var auditLog = new Audit(_dsfDataObject, "LogExecuteException", exception.Message, activity, null, exception);

            LogAuditState(auditLog);
        }
Exemple #6
0
        public void LogExecuteCompleteState(object activity)
        {
            var auditLog = new Audit(_dsfDataObject, "LogExecuteCompleteState", null, activity, null);

            LogAuditState(auditLog);
        }
Exemple #7
0
        public void LogPreExecuteState(IDev2Activity nextActivity)
        {
            var auditLog = new Audit(_dsfDataObject, "LogPreExecuteState", null, null, nextActivity);

            LogAuditState(auditLog);
        }
Exemple #8
0
        public void LogPostExecuteState(IDev2Activity previousActivity, IDev2Activity nextActivity)
        {
            var auditLog = new Audit(_dsfDataObject, "LogPostExecuteState", null, previousActivity, nextActivity);

            LogAuditState(auditLog);
        }