Esempio n. 1
0
 private async Task AppendLogAsync(string logMessage, IDictionary <string, string> eventProperties, ITaskClient taskClient, Guid scopeIdentifier, Guid planId, int taskLogId, CancellationToken cancellationToken)
 {
     try
     {
         using (var logStream = GenerateStreamFromString(logMessage))
         {
             this.AppendTimelineRecordFeed(taskClient, scopeIdentifier, planId, logMessage, cancellationToken);
             await taskClient.AppendLogContentAsync(scopeIdentifier, this.hubName, planId, taskLogId, logStream, userState : null, cancellationToken : cancellationToken).ConfigureAwait(false);
         }
     }
     catch (OperationCanceledException)
     {
     }
     catch (Exception ex)
     {
         await logger.LogException(ex, "VstsLogAppend",
                                   "Failed to append log to VSTS",
                                   eventProperties, cancellationToken).ConfigureAwait(false);
     }
 }
        private async Task AppendLogAsync(string logMessage, IDictionary <string, string> eventProperties, ITaskClient taskClient, Guid scopeIdentifier, Guid planId, int taskLogId, CancellationToken cancellationToken)
        {
            Exception exception = null;

            try
            {
                using (var logStream = GenerateStreamFromString(logMessage))
                {
                    var taskLogResponse = await taskClient.AppendLogContentAsync(scopeIdentifier, this.hubName, planId, taskLogId, logStream, userState : null, cancellationToken : cancellationToken).ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            // c#6.0 allows await inside catch but this code is not 6.0 yet :-(
            if (exception != null && exception.GetType() != typeof(OperationCanceledException))
            {
                await this.baseInstrumentation.HandleException(exception, "VstsLogAppend", "Failed to append log to VSTS", eventProperties, cancellationToken).ConfigureAwait(false);
            }
        }