Esempio n. 1
0
        /// <summary>
        /// Called whenever an exception occured in a logged method.
        /// The existing entry may be closed or opened. If it is opened, we first
        /// send the EventCreated event for the error entry before sending
        /// the EventCreated event for the method itself.
        /// We privilegiate here a hierarchical view: the error will be received before the end of the method.
        /// </summary>
        /// <param name="me">Existing entry.</param>
        /// <param name="ex">Exception raised.</param>
        internal void LogMethodError(LogMethodEntry me, Exception ex)
        {
            LogMethodEntryError         l = new LogMethodEntryError(++_nextLSN, me, ex);
            EventHandler <LogEventArgs> h = EventCreated;

            if (me.SetError(l))
            {
                // Entry was opened.
                --_currentDepth;
                if (h != null)
                {
                    // We first send the "Created" event for the error entry.
                    h(_eventSender, l);
                    // We then send the "Created" event for the method entry.
                    h(_eventSender, me);
                }
                else
                {
                    _untrackedErrors.Add(l);
                }
            }
            else
            {
                // Entry is already closed: just send the error entry.
                if (h != null)
                {
                    h(_eventSender, l);
                }
                else
                {
                    _untrackedErrors.Add(l);
                }
            }
            Debug.Assert(!me.IsCreating, "SetError closed the event, whatever its status was.");
        }
Esempio n. 2
0
 /// <summary>
 /// Setting the error closes the entry if it was opened.
 /// True is returned if the entry has been closed.
 /// </summary>
 internal bool SetError(LogMethodEntryError e)
 {
     _error = e;
     if (LSN < 0)
     {
         LSN = -LSN;
         return(true);
     }
     return(false);
 }
Esempio n. 3
0
 /// <summary>
 /// Setting the error closes the entry if it was opened.
 /// True is returned if the entry has been closed.
 /// </summary>
 internal bool SetError( LogMethodEntryError e )
 {
     _error = e;
     if( LSN < 0 )
     {
         LSN = -LSN;
         return true;
     }
     return false;
 }