/// <summary> /// Create the logger. Set up work in Class initializer, it should also work inside each test. /// </summary> /// <param name="logfile">Path to the file to log into</param> public TestLogger(string logfile, bool update = true) { logfilename = logfile; errorLevel = DataCollectorMessageLevel.Info; if (!update) { try { System.IO.File.Delete(logfile); } catch { } } writer = new TextWriterTraceListener(logfilename); Debug.Listeners.Add(writer); Debug.AutoFlush = true; if (context != null) { Debug.WriteLine("Test Logger: {0} - {1}", context.FullyQualifiedTestClassName, context.TestName); } }
/// <summary> /// Logs and given exception to the client. /// </summary> /// <param name="context"></param> /// <param name="ex">The exception to be logged</param> /// <param name="level"> Is the exception at warning level or error level.</param> /// <remarks> /// When a Data Collector invokes this method, Client would get called on OnCollectionException( ) with a CollectionExceptionMessageEventArgs. /// </remarks> public virtual void LogException(DataCollectionContext context, Exception ex, DataCollectorMessageLevel level) { }