public void TestConsoleLogger() { TheLog.AddProvider(new ConsoleProvider(), LogLevel.Info); _logger.Info("Info"); // will be shown _logger.Trace("Trace"); // will be ignored _logger.Error("Error"); // will be shown }
public void TestFiltering() { var inMemoryProvider = new InMemoryDatabaseProvider(); TheLog.AddProvider(inMemoryProvider, LogLevel.Info); TheLog.Info("Test"); TheLog.Trace("Test2"); TheLog.Error("Test"); Assert.AreEqual(2, inMemoryProvider.Messages.Count); }
public void TestFramework() { var inMemoryProvider = new InMemoryDatabaseProvider(); TheLog.AddProvider(inMemoryProvider, LogLevel.Trace); TheLog.Info("Test"); TheLog.Trace("Test2"); TheLog.Error("Test"); Assert.AreEqual(3, inMemoryProvider.Messages.Count); inMemoryProvider.ClearLog(); Assert.AreEqual(0, inMemoryProvider.Messages.Count); TheLog.Log(LogLevel.Info, "Message"); Assert.AreEqual(1, inMemoryProvider.Messages.Count); }
public void TestClassLogger() { var inMemoryProvider = new InMemoryDatabaseProvider(); TheLog.AddProvider(inMemoryProvider, LogLevel.Info); TheLog.FilterThreshold = LogLevel.Info; _logger.Info("Test"); _logger.Trace("Test2"); _logger.Error("Test"); Assert.AreEqual(2, inMemoryProvider.Messages.Count); Assert.IsTrue(inMemoryProvider.Messages[0].LogMessage.Category.Contains("LoggingTests")); inMemoryProvider.ClearLog(); _logger.Error("Test", "ABC"); Assert.IsTrue(inMemoryProvider.Messages[0].LogMessage.Category.Contains("LoggingTests")); Assert.IsTrue(inMemoryProvider.Messages[0].LogMessage.Category.Contains("ABC")); }
public void TestEventProvider() { var x = 0; var eventHandler = new EventProvider(); eventHandler.MessageReceived += (a, b) => { x++; Assert.AreEqual(LogLevel.Info, b.LogMessage.LogLevel); }; TheLog.FilterThreshold = LogLevel.Trace; TheLog.AddProvider(eventHandler, LogLevel.Trace); Assert.AreEqual(0, x); _logger.Info("Yeah"); Assert.AreEqual(1, x); }
private static void Main() { // Initializes the log TheLog.FilterThreshold = LogLevel.Trace; TheLog.AddProvider(new ConsoleProvider(), LogLevel.Error); TheLog.AddProvider(new FileProvider("maednlog.txt", true)); for (var n = 0; n < 1000; n++) { // Runs the game var gameLogic = new MaednLogic(new MaednConfiguration { NumberOfPlayers = 4 }); gameLogic.Run(); } TheLog.Fatal("Done"); Console.ReadKey(); }
public void TestLogLevel() { var database = new InMemoryDatabaseProvider(); TheLog.FilterThreshold = LogLevel.Trace; TheLog.AddProvider(database, LogLevel.Trace); TheLog.Trace("Test"); Assert.AreEqual(LogLevel.Trace, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel); TheLog.Debug("Test"); Assert.AreEqual(LogLevel.Debug, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel); TheLog.Info("Test"); Assert.AreEqual(LogLevel.Info, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel); TheLog.Warn("Test"); Assert.AreEqual(LogLevel.Warn, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel); TheLog.Error("Test"); Assert.AreEqual(LogLevel.Error, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel); TheLog.Fatal("Test"); Assert.AreEqual(LogLevel.Fatal, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel); }
void ReleaseDesignerOutlets() { if (TheButton != null) { TheButton.Dispose(); TheButton = null; } if (TheTable != null) { TheTable.Dispose(); TheTable = null; } if (TheLog != null) { TheLog.Dispose(); TheLog = null; } }
public void TestFileLogging() { using (var fileProvider = new FileProvider("./test.txt", true)) { TheLog.AddProvider(fileProvider, LogLevel.Info); _logger.Info("Info"); // will be shown _logger.Trace("Trace"); // will be ignored _logger.Error("Error"); // will be shown } var lines = File.ReadAllLines("./test.txt"); Assert.AreEqual(2, lines.Length); Assert.IsTrue(lines[0].Contains("Info")); Assert.IsTrue(lines[1].Contains("Error")); TheLog.ClearProviders(); using (var fileProvider = new FileProvider("./test.txt", false)) { TheLog.AddProvider(fileProvider, LogLevel.Info); _logger.Info("Info"); // will be shown _logger.Trace("Trace"); // will be ignored _logger.Error("Error"); // will be shown } lines = File.ReadAllLines("./test.txt"); Assert.AreEqual(4, lines.Length); TheLog.ClearProviders(); using (var fileProvider = new FileProvider("./test.txt", true)) { TheLog.AddProvider(fileProvider, LogLevel.Info); _logger.Info("Info"); // will be shown _logger.Trace("Trace"); // will be ignored _logger.Error("Error"); // will be shown } lines = File.ReadAllLines("./test.txt"); Assert.AreEqual(2, lines.Length); TheLog.ClearProviders(); }
static void Main(string[] args) { TheLog.AddProvider(new ConsoleProvider(), LogLevel.Trace); TheLog.AddProvider(new FileProvider("test.log", true), LogLevel.Info); TheLog.Trace("Not added"); Thread.Sleep(100); TheLog.Debug("This is a debug message"); Thread.Sleep(80); TheLog.Info("We have an info message."); Thread.Sleep(80); TheLog.Warn("We have a warn"); Thread.Sleep(80); TheLog.Error("Error Occured...."); Thread.Sleep(80); TheLog.Fatal("We have to quit the application due to loss of O²."); Thread.Sleep(80); new WorkingMan().Work(); System.Console.WriteLine("Press key"); System.Console.ReadKey(); }
public void TestClassLoggerLevel() { TheLog.FilterThreshold = LogLevel.Trace; TheLog.AddProvider(InMemoryDatabaseProvider.TheOne, LogLevel.Trace); var database = InMemoryDatabaseProvider.TheOne; var classLogger = new ClassLogger(typeof(LoggingTests)); classLogger.Trace("Test"); Assert.AreEqual(LogLevel.Trace, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel); classLogger.Debug("Test"); Assert.AreEqual(LogLevel.Debug, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel); classLogger.Info("Test"); Assert.AreEqual(LogLevel.Info, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel); classLogger.Warn("Test"); Assert.AreEqual(LogLevel.Warn, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel); classLogger.Error("Test"); Assert.AreEqual(LogLevel.Error, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel); classLogger.Fatal("Test"); Assert.AreEqual(LogLevel.Fatal, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel); classLogger.Log(LogLevel.Debug, "Message"); Assert.AreEqual(LogLevel.Debug, database.Messages[database.Messages.Count - 1].LogMessage.LogLevel); }
public void TestDebug() { TheLog.FilterThreshold = LogLevel.Trace; TheLog.AddProvider(new DebugProvider(), LogLevel.Trace); _logger.Info("Yeah"); }
/// <summary> /// Perform end of import/link cleanup. /// </summary> /// <param name="doc">The document.</param> /// <param name="fileName">The full path of the original IFC file.</param> public void EndImport(Document doc, string fileName) { // Remove an unupdated Elements as a result of a reload operation. try { // We are working around a limitation in deleting unused DirectShapeTypes. IList <ElementId> otherElementsToDelete = new List <ElementId>(); IList <ElementId> typesToDelete = new List <ElementId>(); foreach (ElementId elementId in Importer.TheCache.GUIDToElementMap.Values) { if (DontDeleteSpecialElement(elementId)) { continue; } Element element = doc.GetElement(elementId); if (element == null) { continue; } if (element is DirectShapeType) { typesToDelete.Add(elementId); } else { otherElementsToDelete.Add(elementId); } } foreach (ElementId elementId in Importer.TheCache.GridNameToElementMap.Values) { Element element = doc.GetElement(elementId); if (element == null) { continue; } otherElementsToDelete.Add(elementId); } // Don't expect this to fail. try { if (otherElementsToDelete.Count > 0) { doc.Delete(otherElementsToDelete); } } catch (Exception ex) { TheLog.LogError(-1, ex.Message, false); } // Delete the temporary element we used for validation purposes. IFCGeometryUtil.DeleteSolidValidator(); // This might fail. if (typesToDelete.Count > 0) { doc.Delete(typesToDelete); } UpdateDocumentFileMetrics(doc, fileName); } catch // (Exception ex) { // Catch, but don't report, since this is an internal limitation in the API. //TheLog.LogError(-1, ex.Message, false); } if (m_Transaction != null) { m_Transaction.Commit(); } }