Beispiel #1
0
 public ReportJob(string message, int level, bool timed, ReportJob parentJob = null)
 {
     Disposed       = false;
     Message        = message;
     ParentJob      = parentJob;
     ChildrenTime   = 0.0;
     HierarchyLevel = parentJob == null ? 0 : parentJob.HierarchyLevel + 1;
     Level          = level;
     Progress       = -1.0;
     ReportTests    = false;
     TestInfo       = default(TestInfo);
     if (timed)
     {
         Timer = new Stopwatch(); Timer.Start();
     }
     else
     {
         Timer = null;
     }
 }
Beispiel #2
0
 /// <summary>
 /// Begin a block with a formatted message.
 /// All report calls till the call to the next
 /// <see cref="End()"/> are either indented (console/stream) or
 /// hierarchical children of this block (treeview).
 /// </summary>
 public static void Begin(ReportJob parentJob, [Localizable(true)] string message, params object[] args)
 {
     CountCallsToBegin.Increment();
     s_reporter.Begin(parentJob, 0, RootTarget, Format(message, args), false);
 }
Beispiel #3
0
 /// <summary>
 /// Begin a block without an explicit message.
 /// All report calls till the call to the next
 /// <see cref="End()"/> are either indented (console/stream) or
 /// hierarchical children of this block (treeview).
 /// </summary>
 public static void Begin(ReportJob parentJob)
 {
     CountCallsToBegin.Increment();
     s_reporter.Begin(parentJob, 0, RootTarget, "", false);
 }
Beispiel #4
0
 /// <summary>
 /// Begin a timed block with a formatted message.
 /// All report calls till the call to the next
 /// <see cref="End()"/> are either indented (console/stream) or
 /// hierarchical children of this block (treeview).
 /// At the <see cref="End()"/> of the block the run time is reported.
 /// </summary>
 public static void BeginTimed(ReportJob parentJob, int level, [Localizable(true)] string message, params object[] args)
 {
     CountCallsToBeginTimed.Increment();
     s_reporter.Begin(parentJob, level, RootTarget, Format(message, args), true);
 }
Beispiel #5
0
 /// <summary>
 /// Begin a block with a formatted message.
 /// All report calls till the call to the next
 /// <see cref="End()"/> are either indented (console/stream) or
 /// hierarchical children of this block (treeview).
 /// </summary>
 public static ReportJob Job(ReportJob parentJob, int level, [Localizable(true)] string message, params object[] args)
 {
     CountCallsToBegin.Increment();
     return(s_reporter.Begin(parentJob, level, RootTarget, Format(message, args), false));
 }
Beispiel #6
0
 /// <summary>
 /// Begin a timed block with a formatted message.
 /// All report calls till the call to the next
 /// <see cref="End()"/> are either indented (console/stream) or
 /// hierarchical children of this block (treeview).
 /// At the <see cref="End()"/> of the block the run time is reported.
 /// </summary>
 public static ReportJob JobTimed(ReportJob parentJob, [Localizable(true)] string message, params object[] args)
 {
     CountCallsToBeginTimed.Increment();
     return(s_reporter.Begin(parentJob, 0, RootTarget, Format(message, args), true));
 }
Beispiel #7
0
        public double End(int level, ILogTarget target, string text, bool addTimeToParent)
        {
            var    parentJob = m_job.ParentJob;
            double seconds; string time; LogOpt opt;

            if (m_job.Timer != null)
            {
                seconds = m_job.Timer.ElapsedMilliseconds * 0.001; opt = LogOpt.EndLine | LogOpt.Timed;
                time    = String.Format(CultureInfo.InvariantCulture, "{0:F3} s", seconds);
            }
            else
            {
                seconds = 0.0; time = null; opt = LogOpt.EndLine;
            }
            m_job.Disposed = true;
            if (level != m_job.Level)
            {
                Report.Warn("Report.Begin({0}) level different from Report.End({1}),"
                            + " using Report.End({0})", m_job.Level, level);
                level = m_job.Level;
            }
            var beginText = m_job.Message;

            if (text == null)
            {
                text = beginText;
            }
            else if (text != beginText)
            {
                text = beginText + text; opt |= LogOpt.NewText;
            }
            if (m_job.ReportTests == true)
            {
                var testInfo = m_job.TestInfo;
                if (m_jobStack.Count > 0)
                {
                    m_job = m_jobStack.Pop(); m_job.TestInfo += testInfo;
                }
                else
                {
                    Report.Warn("superfluous Report.End() encountered");
                }
                var passed = String.Format(CultureInfo.InvariantCulture,
                                           "[{0}/{1} OK]", testInfo.PassedCount, testInfo.TestCount);
                time = time != null ? passed + ' ' + time : passed;
                target.Log(m_ti, new LogMsg(LogType.End, opt, level, parentJob.HierarchyLevel * m_indent,
                                            text, -2, time));
                if (testInfo.FailedCount > 0)
                {
                    var failed = String.Format(CultureInfo.InvariantCulture,
                                               " {0}/{1} FAILED", testInfo.FailedCount, testInfo.TestCount);
                    target.Log(m_ti, new LogMsg(LogType.Warn, opt, level, parentJob.HierarchyLevel * m_indent,
                                                "WARNING: " + text + failed));
                }
            }
            else
            {
                var childrenTime = m_job.ChildrenTime;
                if (seconds > 0.0 && childrenTime > 0.0)
                {
                    time = String.Format(CultureInfo.InvariantCulture, "[{0:F2}x] ", childrenTime / seconds) + time;
                }
                if (addTimeToParent)
                {
                    lock (parentJob) parentJob.ChildrenTime += seconds;
                }
                if (m_jobStack.Count > 0)
                {
                    m_job = m_jobStack.Pop();
                }
                else
                {
                    Report.Warn("superfluous Report.End() encountered");
                }
                target.Log(m_ti, new LogMsg(LogType.End, opt, level, parentJob.HierarchyLevel * m_indent,
                                            text, -2, time));
            }
            var reporterArray = m_reporterArray;

            if (reporterArray != null)
            {
                for (int i = 1; i < reporterArray.Length; i++)
                {
                    reporterArray[i].End(m_ti, level, target, text, seconds);
                }
            }
            return(seconds);
        }
 public ReportJob Begin(ReportJob parentJob, int level, ILogTarget target, string text, bool timed, bool noLog = false)
 {
     return(CurrentReporter(target).Begin(parentJob, level, target, text, timed, noLog));
 }