public override void OnInvoke(PostSharp.Aspects.MethodInterceptionArgs args) { string exContext = string.Format(System.Globalization.CultureInfo.InvariantCulture, _context, args.Arguments.ToArray()); using (log4net.ThreadContext.Stacks[Zieschang.Net.Projects.PostsharpAspects.Utilities.LogHelper.DefaultLoggerContextStack].Push(exContext)) { args.Proceed(); } }
public override void OnInvoke(PostSharp.Aspects.MethodInterceptionArgs args) { int counter = 0; object instance = args.Instance; log4net.ILog lg = null; if (_staticInstanceField == null) { lg = InternalFieldFinder.Instance.GetInstance<log4net.ILog>(args.Method, instance); } else { lg = _staticInstanceField; } do { //delay on each cycle before continue //in future use a strategy if (counter > 0 && RetryDelay > 0) System.Threading.Thread.Sleep(RetryDelay); counter++; try { args.Proceed(); counter = Int32.MaxValue; } catch (Exception ex) { if (ExceptionFilterType == null || ExceptionFilterType.IsAssignableFrom(ex.GetType())) { if (counter < _maxRetries) { lg.Info(string.Format(System.Globalization.CultureInfo.InvariantCulture, _retryMessage, counter), ex); } else { string msg = string.Format(System.Globalization.CultureInfo.InvariantCulture, _failureMessage, counter); if (!string.IsNullOrEmpty(_message)) msg = Message + " " + msg; lg.Error(msg, ex); if (_raiseAfterRetries) throw; } } } } while (counter < _maxRetries); }
/// <summary> /// </summary> /// <param name="args"></param> public override void OnInvoke(PostSharp.Aspects.MethodInterceptionArgs args) { string msg = string.Format(Message, args.Arguments); using(new Profiler(msg, _typeName,Level, EnableHirachy)) args.Proceed(); }