internal void Trace(ErlTraceLevel type, Direction dir, string msg) { if (m_OnTrace != null && ErlApp.TraceEnabled(type, TraceLevel)) { m_OnTrace(type, dir, msg); } }
protected internal void OnTrace(ErlTraceLevel type, Direction dir, string msg) { if (ErlApp.TraceEnabled(type, TraceLevel)) { OnTraceCore(type, dir, msg); } }
internal void Trace(ErlTraceLevel type, Direction dir, Func <string> msgFunc) { if (m_OnTrace != null && ErlApp.TraceEnabled(type, TraceLevel)) { m_OnTrace(type, dir, msgFunc()); } }
protected internal virtual void OnTrace(ErlTraceLevel type, Direction dir, Func <string> msgFunc) { if (ErlApp.TraceEnabled(type, TraceLevel)) { var msg = msgFunc(); OnTraceCore(type, dir, msg); } }
protected internal void OnTrace(ErlTraceLevel type, Direction dir, string msg, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) { if (ErlApp.TraceEnabled(type, TraceLevel)) { OnTraceCore(type, dir, msg, file, line); } }
protected internal virtual void OnTrace(ErlTraceLevel type, Direction dir, Func <string> msgFunc, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) { if (ErlApp.TraceEnabled(type, TraceLevel)) { var msg = msgFunc(); OnTraceCore(type, dir, msg, file, line); } }
// used by Send and SendReg (message types with payload) protected void DoSend(ErlOutputStream header, ErlOutputStream payload = null) { bool tw = ErlApp.TraceEnabled(TraceLevel, ErlTraceLevel.Wire); bool ts = ErlApp.TraceEnabled(TraceLevel, ErlTraceLevel.Send); if (tw || ts) { var h = header.InputStream(5).Read(true); m_Home.OnTrace(ErlTraceLevel.Wire, Direction.Outbound, () => { var hb = header.ToBinary(); return("{0} {1} (header_sz={2}{3})\n Header: {4}{5}" .Args(HeaderType(h), h.ToString(), hb.Length, payload == null ? string.Empty : ", msg_sz={0}".Args(payload.Length), hb.ToBinaryString(), payload == null ? string.Empty : "\n Msg: {0}".Args(payload.ToBinaryString()))); }); m_Home.OnTrace(ErlTraceLevel.Send, Direction.Outbound, () => { var o = payload == null ? "" : payload.InputStream(0).Read(true).ToString(); return("{0} {1} {2}".Args(HeaderType(h), h.ToString(), o)); }); } var written = (int)header.Length; lock (m_TcpClient) { try { header.WriteTo(m_TcpClient.GetStream()); if (payload != null) { written += (int)payload.Length; payload.WriteTo(m_TcpClient.GetStream()); } m_SentBytes += written; m_SentMsgs++; } catch (Exception e) { Close(); throw e; } } onReadWrite(Direction.Outbound, written, m_SentBytes, m_SentMsgs); }
protected virtual void OnTraceCore(ErlTraceLevel type, Direction dir, string msg, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0) { if (Trace != null) { Trace(this, type, dir, msg); } if (TraceToLog && ErlApp.TraceEnabled(type, TraceLevel)) { Log(MessageType.TraceErl, "OnTraceCore({0},{1})".Args(type, dir), msg, file: file, line: line); } }
protected virtual void OnTraceCore(ErlTraceLevel type, Direction dir, string msg) { if (Trace != null) { Trace(this, type, dir, msg); } if (TraceToLog && ErlApp.TraceEnabled(type, TraceLevel)) { App.Log.Write(new NFX.Log.Message { Type = Log.MessageType.TraceErl, Topic = "{0}.{1}".Args(CoreConsts.ERLANG_TOPIC, type), From = this.ToString(), Text = msg }); } }