Ejemplo n.º 1
0
 public void WriteInfo(TraceType traceType, string format, params object[] args)
 {
     if (!string.IsNullOrEmpty(this.TraceId))
     {
         TraceSource.WriteInfoWithId(traceType.Name, this.TraceId, format, args);
     }
     else
     {
         TraceSource.WriteInfo(traceType.Name, format, args);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// This API supports the Service Fabric platform and is not meant to be called from your code
        /// </summary>
        /// <param name="t">This API supports the Service Fabric platform and is not meant to be called from your code</param>
        /// <param name="actionId">This API supports the Service Fabric platform and is not meant to be called from your code</param>
        /// <param name="actionName">This API supports the Service Fabric platform and is not meant to be called from your code</param>
        protected void HandleTaskComplete(Task t, string actionId, string actionName)
        {
            Log.WriteInfoWithId("Action '{0}' completed with status: '{1}'.", actionName, t.Status.ToString());
            if (t.Exception != null)
            {
                t.Exception.Handle(ex =>
                {
                    var exceptionToTrace = ex is AggregateException ? (ex as AggregateException).Flatten().InnerException : ex;

                    if (exceptionToTrace is FabricValidationException)
                    {
                        // Return false since FabricValidationException should not be handled
                        return(false);
                    }
                    else
                    {
                        this.ReportProgress(
                            "Action {0}. Failed with exception {1}, HResult {2}. Ignoring since state might have changed during action",
                            actionName,
                            exceptionToTrace.GetType().Name,
                            exceptionToTrace.HResult);

                        Log.WriteInfoWithId(
                            TraceType,
                            actionId,
                            "Action {0}. Failed with exception {1}.",
                            actionName,
                            exceptionToTrace);

                        // Exception will be propagated if total consecutive failures greater than MaxConsecutiveFailures
                        return(this.RecordError()); // throwing the exception if false
                    }
                });
            }
            else
            {
                this.RecordSuccess();
            }
        }
Ejemplo n.º 3
0
 public static void WriteInfo(this TraceType traceType, string format, params object[] args)
 {
     traceSource.WriteInfoWithId(traceType.Name, traceType.Id, format, args);
     ConditionalConsoleWriteLine(format, args);
 }