Mercurial > pub > ImplabNet
changeset 133:6c49d02a9a05 v2
sync
author | cin |
---|---|
date | Mon, 09 Feb 2015 00:28:13 +0300 |
parents | 5fb2bbffdece |
children | 04d4c92d0f28 |
files | Implab/Diagnostics/ConsoleTraceListener.cs Implab/Diagnostics/TraceContext.cs Implab/Diagnostics/TraceEvent.cs Implab/Safe.cs |
diffstat | 4 files changed, 18 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/Implab/Diagnostics/ConsoleTraceListener.cs Sat Feb 07 19:41:31 2015 +0300 +++ b/Implab/Diagnostics/ConsoleTraceListener.cs Mon Feb 09 00:28:13 2015 +0300 @@ -23,10 +23,10 @@ for (int i = 0; i < text.indent; i++) msg.Append(" "); - msg.AppendFormat("[{0}]:{1}: {2}", args.ThreadId, channel, text.content); + msg.AppendFormat("[{0}]: {1}", args.ThreadId, text.content); lock (_consoleLock) { - //Console.ForegroundColor = (ConsoleColor)(args.ThreadId % 15 + 1); + Console.ForegroundColor = (ConsoleColor)(args.ThreadId % 15 + 1); Console.WriteLine(msg); } }
--- a/Implab/Diagnostics/TraceContext.cs Sat Feb 07 19:41:31 2015 +0300 +++ b/Implab/Diagnostics/TraceContext.cs Mon Feb 09 00:28:13 2015 +0300 @@ -41,10 +41,10 @@ } public void EnterLogicalOperation(LogicalOperation operation, bool takeOwnership) { - var prev = CurrentOperation; + //var prev = CurrentOperation; m_stack.Push(m_current); m_current = new OperationContext(operation, takeOwnership); - LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(takeOwnership ? TraceEventType.Attach : TraceEventType.Enter, String.Format("{0} -> {1}",prev.Name, operation.Name))); + //LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(takeOwnership ? TraceEventType.Attach : TraceEventType.Enter, String.Format("{0} -> {1}",prev.Name, operation.Name))); } public void StartLogicalOperation(string name) { @@ -63,16 +63,16 @@ public LogicalOperation DetachLogicalOperation() { var prev = m_current.DetachLogicalOperation(); - LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Detach, String.Format("{0} -> {1}",prev.Name, CurrentOperation.Name))); + //LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Detach, String.Format("{0} -> {1}",prev.Name, CurrentOperation.Name))); return prev; } public void Leave() { if (m_stack.Count > 0) { m_current.Leave(); - var prev = CurrentOperation; + //var prev = CurrentOperation; m_current = m_stack.Pop(); - LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Leave, String.Format("{0} -> {1}", prev.Name, CurrentOperation.Name))); + //LogChannel<TraceEvent>.Default.LogEvent(new TraceEvent(TraceEventType.Leave, String.Format("{0} -> {1}", prev.Name, CurrentOperation.Name))); } else { TraceLog.TraceWarning("Attempt to leave the last operation context"); m_current = OperationContext.EMPTY;
--- a/Implab/Diagnostics/TraceEvent.cs Sat Feb 07 19:41:31 2015 +0300 +++ b/Implab/Diagnostics/TraceEvent.cs Mon Feb 09 00:28:13 2015 +0300 @@ -18,7 +18,8 @@ } public override string ToString() { - return EventType == TraceEventType.Information ? Message : String.Format("{0}: {1}", EventType, Message); + /*return EventType == TraceEventType.Information ? Message : String.Format("{0}: {1}", EventType, Message);*/ + return Message; } public static TraceEvent Create(TraceEventType type, string format, params object[] args) {
--- a/Implab/Safe.cs Sat Feb 07 19:41:31 2015 +0300 +++ b/Implab/Safe.cs Mon Feb 09 00:28:13 2015 +0300 @@ -89,15 +89,19 @@ public static IPromise InvokePromise(Func<IPromise> action) { ArgumentNotNull(action, "action"); - var p = new Promise(); try { - action(); - p.Resolve(); + var p = action(); + if (p == null) { + var d = new Promise(); + d.Reject(new Exception("The action returned null")); + p = d; + } + return p; } catch (Exception err) { + var p = new Promise(); p.Reject(err); + return p; } - - return p; } [DebuggerStepThrough]