public TaskLogEntry(Task task, TaskLogEntryType type, Thread thread, Exception exception)
 {
     Task      = task;
     Type      = type;
     Thread    = thread;
     Exception = exception;
 }
		protected virtual IEnumerable<String> BuildLogEntryFields(SchedulerEngineBase engine, TaskLogEntryType type, ISchedulerTask task, DateTime taskStartedOn, String additionalInfo)
		{
			yield return DateTime.Now.ToString("s");
			yield return engine.Name;
			yield return type.ToString();
			yield return task.GetType().Name;
			yield return (DateTime.Now - taskStartedOn).ToString();
			yield return WrapAsCsvValue(additionalInfo);
		}
 protected virtual void WriteSchedulerMessage(TaskLogEntryType type, string message)
 {
     //duplicate logged messages to console if working on console mode:
     if (Environment.UserInteractive)
     {
         Console.Write(message);
     }
     lock (TaskLogLock) { File.AppendAllText(this.TaskLogFile.FullName, message); }
 }
        public void LogTaskMessage(SchedulerEngineBase engine, TaskLogEntryType type, ISchedulerTask task, DateTime taskStartedOn, String additionalInfo)
        {
            if (!this.ShouldLog(type))
            {
                return;
            }
            var values = BuildLogEntryFields(engine, type, task, taskStartedOn, additionalInfo);
            var entry  = String.Join(", ", values);

            WriteSchedulerMessage(type, PolishMessage(entry));
        }
Ejemplo n.º 5
0
 private static void AddToLog(Task task, TaskLogEntryType type, Exception e = null)
 => log.Add(new TaskLogEntry(task, type, Thread.CurrentThread, e));
		public void LogTaskMessage(SchedulerEngineBase engine, TaskLogEntryType type, ISchedulerTask task, DateTime taskStartedOn, String additionalInfo)
		{
			if (!this.ShouldLog(type)) { return; }
			var values = BuildLogEntryFields(engine, type, task, taskStartedOn, additionalInfo);
			var entry = String.Join(", ", values);
			WriteSchedulerMessage(type, PolishMessage(entry));
		}
		protected virtual Boolean ShouldLog(TaskLogEntryType type)
		{
			return type != TaskLogEntryType.TaskStarting;
		}
		protected virtual void WriteSchedulerMessage(TaskLogEntryType type, string message)
		{
			//duplicate logged messages to console if working on console mode:
			if (Environment.UserInteractive) { Console.Write(message); }
			lock (TaskLogLock) { File.AppendAllText(this.TaskLogFile.FullName, message); }
		}
        protected virtual IEnumerable <String> BuildLogEntryFields(SchedulerEngineBase engine, TaskLogEntryType type, ISchedulerTask task, DateTime taskStartedOn, String additionalInfo)
        {
            yield return(DateTime.Now.ToString("s"));

            yield return(engine.Name);

            yield return(type.ToString());

            yield return(task.GetType().Name);

            yield return((DateTime.Now - taskStartedOn).ToString());

            yield return(WrapAsCsvValue(additionalInfo));
        }
 protected virtual Boolean ShouldLog(TaskLogEntryType type)
 {
     return(type != TaskLogEntryType.TaskStarting);
 }