public void LoadReaderLogs(IJsonLogParser parser, IJsonLogStoringService storingService, string fileName) { var logRecord = new ReaderLogRecord { Logger = "test" }; parser.ReadFile <ReaderLogRecord>(fileName).Returns(new List <ReaderLogRecord> { logRecord }); var loader = new AppLogLoader(parser, storingService); loader.LoadReaderLogs(fileName); storingService.Received(1).BeginWork(); storingService.Received(1).RegisterReaderLogItem(logRecord); }
public void RegisterReaderLogItem(ReaderLogRecord logRecord) { var hash = logRecord.GetSourceLogHash(); if (!_importedReaderLogs.Add(hash)) { return; } ReaderLogRecord.Messageobject msg = logRecord.MessageObject; if (msg == null) { return; } string query = msg.Sql.ExtractLogSqlText(); Guid textId = _queryTextStoringService.GetOrCreate(query, "ReaderLog"); string stackTrace = msg.StackTrace.NormalizeReaderStack(); Guid stackId = _stackStoringService.GetOrCreate(stackTrace, "ReaderLog"); var item = _dateRepository.CreateInfoRecord <ReaderLog>(logRecord.Date); item.QueryId = textId; item.StackId = stackId; item.Rows = msg.RowsAffected?.Sum() ?? 0; _pendingReaderLogs.Add(item); }