Example #1
0
        /// <summary>
        /// Begins a logical operation scope.
        /// </summary>
        /// <typeparam name="TState"></typeparam>
        /// <param name="state">The identifier for the scope.</param>
        /// <returns>
        /// An IDisposable that ends the logical operation scope on dispose.
        /// </returns>
        public IDisposable BeginScope <TState>(TState state)
        {
            Assumption.AssertTrue(state != null, nameof(state));

            var scope = new RollbarScope(_name, state);

            scope.HttpContext = RollbarScope.Current?.HttpContext ?? new RollbarHttpContext();
            return(RollbarScope.Push(scope));
        }
Example #2
0
        public static IDisposable Push(RollbarScope scope)
        {
            Assumption.AssertNotNull(scope, nameof(scope));

            var temp = Current;

            Current      = scope;
            Current.Next = temp;

            return(new DisposableAction(
                       () => { RollbarScope.Current = RollbarScope.Current.Next; }
                       ));
        }