/// <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."); }
/// <summary> /// Called when a method is entered. /// </summary> /// <param name="m"></param> /// <param name="logOptions"></param> /// <returns></returns> internal LogMethodEntry LogMethodEnter(MethodInfo m, ServiceLogMethodOptions logOptions) { Debug.Assert(logOptions != 0); LogMethodEntry me = new LogMethodEntry(); if ((logOptions & ServiceLogMethodOptions.Leave) == 0) { me.InitClose(++_nextLSN, _currentDepth, m); // Emits the "Created" event. EventHandler <LogEventArgs> h = EventCreated; if (h != null) { h(_eventSender, me); } } else { me.InitOpen(++_nextLSN, _currentDepth++, m); // Emits the "Creating" event. EventHandler <LogEventArgs> h = EventCreating; if (h != null) { h(_eventSender, me); } } return(me); }
internal LogMethodEntryError(int lsn, LogMethodEntry e, Exception ex) { Debug.Assert(e != null && ex != null); LSN = lsn; _entry = e; _exception = ex; }
internal LogMethodEntryError( int lsn, LogMethodEntry e, Exception ex ) { Debug.Assert( e != null && ex != null ); LSN = lsn; _entry = e; _exception = ex; }
protected ServiceLogMethodOptions GetLoggerForAnyCall(int iMethodMRef, out LogMethodEntry logger) { MEntry me = _mRefs[iMethodMRef]; ServiceLogMethodOptions o = me.LogOptions; logger = o == ServiceLogMethodOptions.None ? null : _serviceHost.LogMethodEnter(me.Method, o); return(o); }
protected void OnCallException(int iMethodMRef, Exception ex, LogMethodEntry e) { if (e != null) { _serviceHost.LogMethodError(e, ex); } else { MEntry me = _mRefs[iMethodMRef]; _serviceHost.LogMethodError(me.Method, ex); } }
/// <summary> /// Called when a method with an opened entry succeeds. /// </summary> /// <param name="me"></param> internal void LogMethodSuccess(LogMethodEntry me) { Debug.Assert(me.IsCreating); --_currentDepth; me.Close(); EventHandler <LogEventArgs> h = EventCreated; if (h != null) { h(_eventSender, me); } }
protected ServiceLogMethodOptions GetLoggerForRunningCall(int iMethodMRef, out LogMethodEntry logger) { if (_impl == null || _impl.Status == RunningStatus.Disabled) { throw new ServiceNotAvailableException(_typeInterface); } if (_impl.Status == RunningStatus.Stopped) { throw new ServiceStoppedException(_typeInterface); } MEntry me = _mRefs[iMethodMRef]; ServiceLogMethodOptions o = me.LogOptions; o &= ServiceLogMethodOptions.CreateEntryMask; logger = o == ServiceLogMethodOptions.None ? null : _serviceHost.LogMethodEnter(me.Method, o); return(o); }
protected void LogEndCallWithValue(LogMethodEntry e, object retValue) { Debug.Assert(e != null); e._returnValue = retValue; _serviceHost.LogMethodSuccess(e); }
protected void LogEndCall(LogMethodEntry e) { Debug.Assert(e != null); _serviceHost.LogMethodSuccess(e); }
protected void OnCallException( int iMethodMRef, Exception ex, LogMethodEntry e ) { if( e != null ) { _serviceHost.LogMethodError( e, ex ); } else { MEntry me = _mRefs[iMethodMRef]; _serviceHost.LogMethodError( me.Method, ex ); } }
protected void LogEndCallWithValue( LogMethodEntry e, object retValue ) { Debug.Assert( e != null ); e._returnValue = retValue; _serviceHost.LogMethodSuccess( e ); }
protected void LogEndCall( LogMethodEntry e ) { Debug.Assert( e != null ); _serviceHost.LogMethodSuccess( e ); }
protected ServiceLogMethodOptions GetLoggerForAnyCall( int iMethodMRef, out LogMethodEntry logger ) { MEntry me = _mRefs[iMethodMRef]; ServiceLogMethodOptions o = me.LogOptions; logger = o == ServiceLogMethodOptions.None ? null : _serviceHost.LogMethodEnter( me.Method, o ); return o; }
protected ServiceLogMethodOptions GetLoggerForNotDisabledCall( int iMethodMRef, out LogMethodEntry logger ) { if( _impl == null || _impl.Status == RunningStatus.Disabled ) { throw new ServiceNotAvailableException( _typeInterface ); } MEntry me = _mRefs[iMethodMRef]; ServiceLogMethodOptions o = me.LogOptions; o &= ServiceLogMethodOptions.CreateEntryMask; logger = o == ServiceLogMethodOptions.None ? null : _serviceHost.LogMethodEnter( me.Method, o ); return o; }