//-----------------------------------------------------------------------------------------------------------------------------------------------------
        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);
        }
Exemple #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);
        }
 //-----------------------------------------------------------------------------------------------------------------------------------------------------
 protected void BubbleActivityResultsFrom(ActivityLogNode subActivity)
 {
     base.BubbleLogLevelFrom(subActivity.Level);
     base.BubbleContentTypesFrom(subActivity.ContentTypes);
     this.BubbleExceptionFrom(subActivity.Exception);
 }
 //-----------------------------------------------------------------------------------------------------------------------------------------------------
 internal override void AttachToThreadLog(IThreadLog threadLog, ActivityLogNode parent)
 {
     base.AttachToThreadLog(threadLog, parent);
     _parent = parent;
 }
Exemple #6
0
 //-----------------------------------------------------------------------------------------------------------------------------------------------------
 private string ToTestString(ActivityLogNode activity)
 {
     var output = new StringBuilder();
     AppendActivityTestString(activity, output);
     return output.ToString();
 }
Exemple #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("}");
        }
Exemple #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();
            }
        }
Exemple #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)
 {
 }
        //-----------------------------------------------------------------------------------------------------------------------------------------------------
        public void StartThreadLog(ThreadTaskType taskType, ActivityLogNode rootActivity)
        {
            var currentLog = _anchor.CurrentThreadLog;

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