//----------------------------------------------------------------------------------------------------------------------------------------------------- public void StartThreadLog(ThreadTaskType taskType, ActivityLogNode rootActivity) { this.StartedThreadLogIndex = _logNodes.Count; this.StartedThreadTaskType = taskType; _logNodes.Add(rootActivity); rootActivity.AttachToThreadLog(_threadLog, parent: null); }
internal void FastStart(object task, ThreadTaskType taskType) { Thread thread = threads.Pop(); if (thread == null) { new Thread(this, task, taskType); } else { thread.RunTask(task, taskType); System.Threading.Interlocked.Decrement(ref freeThreadCount); } }
//----------------------------------------------------------------------------------------------------------------------------------------------------- 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); }
public void GenerateExampleThreadLogs(ThreadTaskType taskType, string rootActivityText, bool includeWarning, bool includeError) { var realThreadRegistry = new ThreadRegistry(@"D:\ThreadLogExamples"); var rootActivity = new FormattedActivityLogNode(rootActivityText); var log = new ThreadLog(Framework, _clock, realThreadRegistry, taskType, rootActivity); log.AppendNode(new FormattedLogNode(LogLevel.Info, "One")); log.AppendNode(new FormattedActivityLogNode("Two")); log.AppendNode(new FormattedLogNode(LogLevel.Verbose, "Two-1")); log.AppendNode(new FormattedLogNode(LogLevel.Verbose, "Two-2")); log.AppendNode(new FormattedLogNode(LogLevel.Info, "Three")); log.AppendNode(new FormattedActivityLogNode("Four")); if ( includeError ) { try { throw new Exception("This is a generated exception"); } catch ( Exception e ) { log.AppendNode(new FormattedLogNode(LogLevel.Error, "Five", exception: e, fullDetailsText: e.ToString())); } } log.CurrentActivity.Close(); if ( includeWarning ) { log.AppendNode(new FormattedLogNode(LogLevel.Warning, "Six")); } log.AppendNode(new FormattedLogNode(LogLevel.Debug, "Two-3")); log.AppendNode(new FormattedLogNode(LogLevel.Debug, "Two-4")); Thread.Sleep(5000); }
//----------------------------------------------------------------------------------------------------------------------------------------------------- private ThreadLog CreateThreadLog(string rootActivityText = "Root", ThreadTaskType taskType = ThreadTaskType.Unspecified) { var rootActivity = new FormattedActivityLogNode(rootActivityText); return new ThreadLog(Framework, Clock, Registry, Anchor, ThreadTaskType.Unspecified, rootActivity); }
public void Set(Action value) { Value = value; Type = ThreadTaskType.Action; }
public void Set(object value, ThreadTaskType type) { Value = value; Type = type; }
public LogThreadAttribute(ThreadTaskType taskType) : base(LogLevel.Info, isActivity: true, isThread: true, isMethodCall: false) { base.TaskType = taskType; }
//----------------------------------------------------------------------------------------------------------------------------------------------------- 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); }