Beispiel #1
0
        protected bool GetLoggerEventForRunningCall(int iEventMRef, out LogEventEntry entry, out ServiceLogEventOptions logOptions)
        {
            EEntry e = _eRefs[iEventMRef];

            logOptions = e.LogOptions;
            bool isDisabled = _impl == null || _impl.Status == RunningStatus.Disabled;

            if (isDisabled || _impl.Status == RunningStatus.Stopped)
            {
                if ((logOptions & ServiceLogEventOptions.SilentEventRunningStatusError) != 0)
                {
                    entry = null;
                    if ((logOptions & ServiceLogEventOptions.LogSilentEventRunningStatusError) != 0)
                    {
                        _serviceHost.LogEventNotRunningError(e.Event, isDisabled);
                    }
                    return(false);
                }
                if (isDisabled)
                {
                    throw new ServiceNotAvailableException(_typeInterface);
                }
                else
                {
                    throw new ServiceStoppedException(_typeInterface);
                }
            }
            logOptions &= ServiceLogEventOptions.CreateEntryMask;
            entry       = logOptions != 0 ? _serviceHost.LogEventEnter(e.Event, logOptions) : null;
            return(true);
        }
Beispiel #2
0
        internal LogEventEntry LogEventEnter(EventInfo e, ServiceLogEventOptions logOptions)
        {
            Debug.Assert(logOptions != 0);
            LogEventEntry ee = new LogEventEntry();

            if ((logOptions & ServiceLogEventOptions.EndRaise) == 0)
            {
                ee.InitClose(++_nextLSN, _currentDepth, e);
                // Emits the "Created" event.
                EventHandler <LogEventArgs> h = EventCreated;
                if (h != null)
                {
                    h(_eventSender, ee);
                }
            }
            else //if( (logOptions & ServiceLogEventOptions.StartRaise) != 0) //if we are only logging the EndRaise, we should NOT log through LogEventEnter
            {
                ee.InitOpen(++_nextLSN, _currentDepth++, e);
                // Emits the "Creating" event.
                EventHandler <LogEventArgs> h = EventCreating;
                if (h != null)
                {
                    h(_eventSender, ee);
                }
            }
            return(ee);
        }
Beispiel #3
0
        protected bool GetLoggerEventForAnyCall(int iEventMRef, out LogEventEntry entry, out ServiceLogEventOptions logOptions)
        {
            EEntry e = _eRefs[iEventMRef];

            logOptions = e.LogOptions & ServiceLogEventOptions.CreateEntryMask;
            entry      = logOptions != 0 ? _serviceHost.LogEventEnter(e.Event, logOptions) : null;
            return(true);
        }
Beispiel #4
0
 internal LogEventEntryError(int lsn, LogEventEntry e, MethodInfo target, Exception ex)
 {
     Debug.Assert(e != null && target != null && ex != null);
     LSN        = lsn;
     _entry     = e;
     _target    = target;
     _exception = ex;
 }
Beispiel #5
0
        /// <summary>
        /// Called at the end of an event raising that have an existing opened log entry.
        /// Entries that have been created by <see cref="LogEventError(EventInfo,MethodInfo,Exception)"/> (because an exception
        /// has been raised by at least one receiver) are not tracked.
        /// </summary>
        /// <param name="ee">The entry of the event that ended.</param>
        internal void LogEventEnd(LogEventEntry ee)
        {
            Debug.Assert(ee.IsCreating);
            --_currentDepth;
            ee.Close();
            EventHandler <LogEventArgs> h = EventCreated;

            if (h != null)
            {
                h(_eventSender, ee);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Called whenever the recipient of an event raises an exception and the event log already exists.
        /// This appends the error to the error list of the event entry.
        /// </summary>
        /// <param name="ee">Existing event log entry.</param>
        /// <param name="target">Culprit method.</param>
        /// <param name="ex">Exception raised by the culprit method.</param>
        internal void LogEventError(LogEventEntry ee, MethodInfo target, Exception ex)
        {
            LogEventEntryError l = new LogEventEntryError(++_nextLSN, ee, target, ex);

            ee.AddError(l);
            EventHandler <LogEventArgs> h = EventCreated;

            if (h != null)
            {
                h(_eventSender, l);
            }
            else
            {
                _untrackedErrors.Add(l);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Called whenever the recipient of an event raises an exception and the event is not
        /// yet logged (no <see cref="LogEventEntry"/> exists). This creates the entry for the event
        /// and the associated error.
        /// </summary>
        /// <param name="e">The reflected event info.</param>
        /// <param name="target">Culprit method.</param>
        /// <param name="ex">Exception raised by the culprit method.</param>
        /// <returns>The created event entry that holds the error.</returns>
        internal LogEventEntry LogEventError(EventInfo e, MethodInfo target, Exception ex)
        {
            // This LogEventEntry is an hidden one. We do not emit it.
            LogEventEntry      ee = new LogEventEntry();
            LogEventEntryError l  = new LogEventEntryError(++_nextLSN, ee, target, ex);

            ee.InitError(++_nextLSN, _currentDepth, e, l);

            // Emits the error.
            EventHandler <LogEventArgs> h = EventCreated;

            if (h != null)
            {
                h(_eventSender, l);
            }
            else
            {
                _untrackedErrors.Add(l);
            }

            return(ee);
        }
Beispiel #8
0
        protected bool OnEventHandlingException(int iEventMRef, MethodInfo target, Exception ex, ref LogEventEntry ee)
        {
            EEntry e = _eRefs[iEventMRef];

            if ((e.LogOptions & ServiceLogEventOptions.LogErrors) != 0)
            {
                if (ee != null)
                {
                    _serviceHost.LogEventError(ee, target, ex);
                }
                else
                {
                    ee = _serviceHost.LogEventError(e.Event, target, ex);
                }
            }
            return((e.LogOptions & ServiceLogEventOptions.SilentEventError) != 0);
        }
Beispiel #9
0
 protected void LogEndRaise(LogEventEntry e)
 {
     Debug.Assert(e != null);
     _serviceHost.LogEventEnd(e);
 }