Exemplo n.º 1
0
        public void TestParseFile()
        {
            var entries = _accessLogParser.ParseLogs(LogFileFixture.ReadLogs());

            entries.Should()
            .BeEquivalentTo(LogFileFixture.GetAccessEntries());
        }
Exemplo n.º 2
0
        public Either <string, long> IngestLogs()
        {
            try {
                _logger.LogInformation("looking for previous processed logs");
                var linesProcessed = GetLinesProcessed();

                _logger.LogInformation("the following logs have been already processed: {0}", linesProcessed);

                _logger.LogInformation("getting logs from file");

                var textLogs  = GetLogs(linesProcessed);
                var entryLogs = _accessLogParser.ParseLogs(textLogs);

                _logger.LogInformation("storing logs into DB");

                var entities = BuildAccessLog(entryLogs);

                _dbContext.AccessLogs.AddRange(entities);
                _dbContext.SaveChanges();

                var processedLogs = entryLogs.Count();
                _logger.LogInformation("logs processed: {0}", processedLogs);

                return(processedLogs);
            }
            catch (Exception ex)
            {
                _logger.LogError("can't process logs - ", ex);
                return(string.Format("Can't process log resource: {0}", _accessLog.GetLogResource()));
            }
        }