private void CommandsSource_OnLogMessageCommand(Shared.Execution.ILogContext logContext, Shared.Extensibility.Commands.CommandArgs.LogMessageCommandArgs args) { var logScope = args.LogScope; ITestReporter testReporter; if (logScope != null && ReportPortalAddin.LogScopes.ContainsKey(logScope.Id)) { testReporter = ReportPortalAddin.LogScopes[logScope.Id]; } else { // TODO: investigate SpecFlow how to understand current scenario context testReporter = GetCurrentTestReporter(); } if (testReporter != null) { testReporter.Log(args.LogMessage.ConvertToRequest()); } else { _traceLogger.Warn("Unknown current context to log message."); } }
private void CommandsSource_OnLogMessageCommand(Shared.Execution.ILogContext logContext, Shared.Extensibility.Commands.CommandArgs.LogMessageCommandArgs args) { var rootScope = Context.Current.Log.Root; TraceLogger.Verbose($"Handling log message for {rootScope.GetHashCode()} root scope..."); var logScope = args.LogScope; if (_outputHelperMap.TryGetValue(rootScope, out ITestOutputHelper output)) { var logRequest = args.LogMessage.ConvertToRequest(); var sharedLogMessage = new AddLogCommunicationMessage { ParentScopeId = logScope?.Id, Level = logRequest.Level, Time = logRequest.Time, Text = logRequest.Text }; if (logRequest.Attach != null) { sharedLogMessage.Attach = new Attach(logRequest.Attach.MimeType, logRequest.Attach.Data); } NotifyAgent(output, Client.Converters.ModelSerializer.Serialize <AddLogCommunicationMessage>(sharedLogMessage)); } }