private static void Warning(UnhandledException ex, Current current) { Debug.Assert(current.Adapter.Communicator != null); var output = new System.Text.StringBuilder(); output.Append("dispatch exception:"); output.Append("\nidentity: ").Append(current.Identity.ToString(current.Adapter.Communicator.ToStringMode)); output.Append("\nfacet: ").Append(StringUtil.EscapeString(current.Facet, "", current.Adapter.Communicator.ToStringMode)); output.Append("\noperation: ").Append(current.Operation); if (current.Connection != null) { try { for (ConnectionInfo?p = current.Connection.GetConnectionInfo(); p != null; p = p.Underlying) { if (p is IPConnectionInfo ipinfo) { output.Append("\nremote host: ").Append(ipinfo.RemoteAddress) .Append(" remote port: ") .Append(ipinfo.RemotePort); break; } } } catch (Exception) { } } output.Append("\n"); output.Append(ex.ToString()); current.Adapter.Communicator.Logger.Warning(output.ToString()); }
/// <summary>Converts an object identity to a string.</summary> /// <param name="mode">Specifies if and how non-printable ASCII characters are escaped in the result.</param> /// <returns>The string representation of the object identity.</returns> public string ToString(ToStringMode mode) { if (string.IsNullOrEmpty(Category)) { return(StringUtil.EscapeString(Name, "/", mode)); } else { return(StringUtil.EscapeString(Category, "/", mode) + '/' + StringUtil.EscapeString(Name, "/", mode)); } }
private static void TraceRequest( string traceFramePrefix, Communicator communicator, Protocol protocol, byte frameType, byte compress, int size, int requestId, Identity identity, string facet, string operation, bool isIdempotent, IReadOnlyDictionary <string, string> context, Encoding encoding) { if (communicator.TraceLevels.Protocol >= 1) { var s = new StringBuilder(); s.Append(traceFramePrefix); PrintHeader(protocol, frameType, compress, size, s); PrintRequestId(requestId, s); ToStringMode toStringMode = communicator.ToStringMode; s.Append("\nidentity = "); s.Append(identity.ToString(toStringMode)); s.Append("\nfacet = "); if (facet.Length > 0) { s.Append(StringUtil.EscapeString(facet, "", toStringMode)); } s.Append("\noperation = "); s.Append(operation); OperationMode mode = isIdempotent ? OperationMode.Idempotent : OperationMode.Normal; s.Append("\noperation mode = "); s.Append((byte)mode); s.Append(mode switch { OperationMode.Normal => " (non-idempotent)", _ => " (idempotent)", });
/// <summary>Converts an object identity to a string, using the format specified by ToStringMode.</summary> /// <param name="mode">Specifies if and how non-printable ASCII characters are escaped in the result. See /// <see cref="ToStringMode"/>.</param> /// <returns>The string representation of the object identity.</returns> public string ToString(ToStringMode mode) { if (string.IsNullOrEmpty(Name)) { return(""); } Debug.Assert(Category != null); string escapedName = StringUtil.EscapeString(Name, mode, '/'); if (Category.Length == 0) { return(escapedName); } else { string escapedCategory = StringUtil.EscapeString(Category, mode, '/'); return($"{escapedCategory}/{escapedName}"); } }
private static void Warning(UnhandledException ex, Current current) { Debug.Assert(current.Adapter.Communicator != null); var output = new System.Text.StringBuilder(); output.Append("dispatch exception:"); output.Append("\nidentity: ").Append(current.Identity.ToString(current.Communicator.ToStringMode)); output.Append("\nfacet: ").Append( StringUtil.EscapeString(current.Facet, current.Communicator.ToStringMode)); output.Append("\noperation: ").Append(current.Operation); if ((current.Connection as IPConnection)?.RemoteEndpoint is System.Net.IPEndPoint remoteEndpoint) { output.Append("\nremote address: ").Append(remoteEndpoint); } output.Append('\n'); output.Append(ex.ToString()); current.Adapter.Communicator.Logger.Warning(output.ToString()); }