public void TraceEventHelper(TraceEventType severity, int traceCode, string traceDescription, Exception e,
                string action, PeerNeighborState nbrState, PeerNeighborState previousOrAttemptedState)
            {
                if (DiagnosticUtility.ShouldTrace(severity))
                {
                    string attemptedState = null;
                    string previousState = null;
                    PeerNodeAddress listenAddr = null;
                    IPAddress connectIPAddr = null;

                    if (nbrState >= PeerNeighborState.Opened && nbrState <= PeerNeighborState.Connected)
                    {
                        listenAddr = this.ListenAddress;
                        connectIPAddr = this.ConnectIPAddress;
                    }

                    if (traceCode == TraceCode.PeerNeighborStateChangeFailed)
                        attemptedState = previousOrAttemptedState.ToString();
                    else if (traceCode == TraceCode.PeerNeighborStateChanged)
                        previousState = previousOrAttemptedState.ToString();

                    PeerNeighborTraceRecord record = new PeerNeighborTraceRecord(this.nodeId,
                        this.config.NodeId, listenAddr, connectIPAddr, this.GetHashCode(),
                        this.initiator, nbrState.ToString(), previousState, attemptedState, action);

                    if (severity == TraceEventType.Verbose && e != null)
                        severity = TraceEventType.Information; // need to be >= info for exceptions

                    TraceUtility.TraceEvent(severity, traceCode, traceDescription, record, this, e);
                }
            }
 private IPeerNeighbor GetNeighbor()
 {
     IPeerNeighbor neighbor = this.getNeighborCallback(OperationContext.Current.GetCallbackChannel<IPeerProxy>());
     if ((neighbor == null) || (neighbor.State == PeerNeighborState.Closed))
     {
         if (DiagnosticUtility.ShouldTraceWarning)
         {
             TraceUtility.TraceEvent(TraceEventType.Warning, 0x40036, System.ServiceModel.SR.GetString("TraceCodePeerNeighborNotFound"), new PeerNodeTraceRecord(this.config.NodeId), OperationContext.Current.IncomingMessage);
         }
         return null;
     }
     if (DiagnosticUtility.ShouldTraceVerbose)
     {
         PeerNeighborState state = neighbor.State;
         PeerNodeAddress listenAddress = null;
         IPAddress connectIPAddress = null;
         if ((state >= PeerNeighborState.Opened) && (state <= PeerNeighborState.Connected))
         {
             listenAddress = this.config.GetListenAddress(true);
             connectIPAddress = this.config.ListenIPAddress;
         }
         PeerNeighborTraceRecord extendedData = new PeerNeighborTraceRecord(neighbor.NodeId, this.config.NodeId, listenAddress, connectIPAddress, neighbor.GetHashCode(), neighbor.IsInitiator, state.ToString(), null, null, OperationContext.Current.IncomingMessage.Headers.Action);
         TraceUtility.TraceEvent(TraceEventType.Verbose, 0x4003a, System.ServiceModel.SR.GetString("TraceCodePeerNeighborMessageReceived"), extendedData, this, null);
     }
     return neighbor;
 }