public async Task FunctionHandler(S3NotificationEvent input, ILambdaContext context) { var data = input?.GetFileData(); var retriever = new S3ObjectRetriever(data.Value.objectsKey, RegionEndpoint.GetBySystemName(data.Value.region)); using var connection = new DbConnection(); await connection.GetConnection().OpenAsync().ConfigureAwait(false); var logSaver = new LogSaver(connection.GetConnection()); string logId = await logSaver.GetAssociatedLogIdAsync(data.Value.objectsKey).ConfigureAwait(false); if (!String.IsNullOrEmpty(logId)) { var entries = retriever.GetObjectDataAsync().Select( logLine => EntryParser.ProcessLogLine(logLine)); await logSaver.SaveLogsAsync(logId, entries).ConfigureAwait(false); if (NotificationSender.IsNotificationNecessary(data.Value.objectsKey)) { await NotificationSender.TryPublishNotification(data.Value.objectsKey).ConfigureAwait(false); } } else { throw new Exception($"Log with given object name " + $"({data.Value.objectsKey}) has no associated record in database"); } }
public void TestProcessLogLineMatchUserAgent(string logLine, string expectedUserAgent) { var logEntry = EntryParser.ProcessLogLine(logLine); Assert.Equal(expectedUserAgent, logEntry.UserAgent); }
public void TestProcessLogLineMatchRawEntry(string logLine) { var logEntry = EntryParser.ProcessLogLine(logLine); Assert.Equal(logLine, logEntry.RawEntry); }
public void TestProcessLogLineMatchResponseCode(string logLine, int expectedResponseCode) { var logEntry = EntryParser.ProcessLogLine(logLine); Assert.Equal(expectedResponseCode, logEntry.ResponseCode); }
public void TestProcessLogLineMatchIP(string logLine, string expectedIP) { var logEntry = EntryParser.ProcessLogLine(logLine); Assert.Equal(expectedIP, logEntry.ClientIp); }
public void TestProcessLogLineMatchRequestTime(string logLine, DateTime expectedRequestTime) { var logEntry = EntryParser.ProcessLogLine(logLine); Assert.Equal(expectedRequestTime, logEntry.RequestTime); }
public void TestProcessLogLineMatchResource(string logLine, string expectedResource) { var logEntry = EntryParser.ProcessLogLine(logLine); Assert.Equal(expectedResource, logEntry.Resource); }
public void TestProcessLogLineMatchMethod(string logLine, LogEntry.RequestType expectedMethod) { var logEntry = EntryParser.ProcessLogLine(logLine); Assert.Equal(expectedMethod, logEntry.Method); }