//-----------------------------------------------------------------------------------------------------------------------------------------------------
        public void StartThreadLog(ThreadTaskType taskType, ActivityLogNode rootActivity)
        {
            this.StartedThreadLogIndex = _logNodes.Count;
            this.StartedThreadTaskType = taskType;

            _logNodes.Add(rootActivity);
            rootActivity.AttachToThreadLog(_threadLog, parent: null);
        }
        //-----------------------------------------------------------------------------------------------------------------------------------------------------
        public void AppendActivityNode(ActivityLogNode activity)
        {
            var currentLog = _anchor.CurrentThreadLog;

            if ( currentLog != null )
            {
                currentLog.AppendNode(activity);
            }
            else
            {
                StartThreadLogNoCheck(ThreadTaskType.Unspecified, activity);
            }

            _plainLog.LogActivity(activity);
        }
Beispiel #3
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------
        public ThreadLog(
            IFramework framework, IClock clock, IThreadRegistry registry, IThreadLogAnchor anchor, ThreadTaskType taskType, ActivityLogNode rootActivity)
        {
            _registry = registry;
            _anchor = anchor;
            _taskType = taskType;
            _rootActivity = rootActivity;
            _currentActivity = rootActivity;
            _startedAtUtc = framework.UtcNow;
            _logId = framework.NewGuid();
            _correlationId = _logId;
            _node = framework.CurrentNode;
            _clock = clock;

            _rootActivity.AttachToThreadLog(this, parent: null);
            _registry.ThreadStarted(this);
        }
Beispiel #4
0
 //-----------------------------------------------------------------------------------------------------------------------------------------------------
 protected void BubbleActivityResultsFrom(ActivityLogNode subActivity)
 {
     base.BubbleLogLevelFrom(subActivity.Level);
     base.BubbleContentTypesFrom(subActivity.ContentTypes);
     this.BubbleExceptionFrom(subActivity.Exception);
 }
Beispiel #5
0
 //-----------------------------------------------------------------------------------------------------------------------------------------------------
 internal override void AttachToThreadLog(IThreadLog threadLog, ActivityLogNode parent)
 {
     base.AttachToThreadLog(threadLog, parent);
     _parent = parent;
 }
Beispiel #6
0
 //-----------------------------------------------------------------------------------------------------------------------------------------------------
 private string ToTestString(ActivityLogNode activity)
 {
     var output = new StringBuilder();
     AppendActivityTestString(activity, output);
     return output.ToString();
 }
Beispiel #7
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------
        private void AppendActivityTestString(ActivityLogNode activity, StringBuilder output)
        {
            AppendNodeTestString(activity, output);
            output.Append("{");

            for ( var child = activity.FirstChild ; child != null ; child = child.NextSibling )
            {
                if ( child is ActivityLogNode )
                {
                    AppendActivityTestString((ActivityLogNode)child, output);
                }
                else
                {
                    AppendNodeTestString(child, output);
                }

                if ( child.NextSibling != null )
                {
                    output.Append(";");
                }
            }

            output.Append("}");
        }
Beispiel #8
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------
        public void NotifyActivityClosed(ActivityLogNode activity)
        {
            if ( activity != _currentActivity )
            {
                throw new InvalidOperationException("Cannot close actvity because it is not the current activity at the moment.");
            }

            if ( activity.Parent != null )
            {
                _currentActivity = activity.Parent;
            }
            else
            {
                Close();
            }
        }
Beispiel #9
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------
        public void AppendNode(LogNode node, bool clearFailure = false)
        {
            node.AttachToThreadLog(this, _currentActivity);
            _currentActivity.AppendChildNode(node, clearFailure);

            var nodeAsActivity = (node as ActivityLogNode);

            if ( nodeAsActivity != null )
            {
                _currentActivity = nodeAsActivity;
            }
        }
 //-----------------------------------------------------------------------------------------------------------------------------------------------------
 public void AppendActivityNode(ActivityLogNode activity)
 {
     _logNodes.Add(activity);
     activity.AttachToThreadLog(_threadLog, parent: null);
 }
 public void NotifyActivityClosed(ActivityLogNode activity)
 {
 }
Beispiel #12
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------
        public void StartThreadLog(ThreadTaskType taskType, ActivityLogNode rootActivity)
        {
            var currentLog = _anchor.CurrentThreadLog;

            if ( currentLog != null )
            {
                currentLog.AppendNode(rootActivity);
                _plainLog.LogActivity(rootActivity);
            }
            else
            {
                StartThreadLogNoCheck(taskType, rootActivity);
            }
        }
Beispiel #13
0
 //-----------------------------------------------------------------------------------------------------------------------------------------------------
 private void StartThreadLogNoCheck(ThreadTaskType taskType, ActivityLogNode rootActivity)
 {
     _anchor.CurrentThreadLog = new ThreadLog(_framework, new StopwatchClock(), _registry, _anchor, taskType, rootActivity);
     _plainLog.LogActivity(rootActivity);
 }
Beispiel #14
0
 //-----------------------------------------------------------------------------------------------------------------------------------------------------
 internal virtual void AttachToThreadLog(IThreadLog thread, ActivityLogNode parent)
 {
     _threadLog = thread;
     _millisecondsTimestamp = thread.ElapsedThreadMilliseconds;
 }