Allows any problem or issue to be logged via messages or exceptions, usually used by the
MockLogger for tests and ConsoleLogger, TextFileLogger and NetworkLogger in apps.
View code on GitHub
Inheritance Hierarchy
DeltaEngine.Core Logger
DeltaEngine.Core ConsoleLogger
DeltaEngine.Logging NetworkLogger
DeltaEngine.Logging TextFileLogger
DeltaEngine.Logging TextLogger
DeltaEngine.Mocks MockLogger
DeltaEngine.Tests.Core LoggerTests SameThreadLogger
Namespace: DeltaEngine.Core
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The Logger type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Logger | Initializes a new instance of the Logger class |
Methods
Name | Description | |
---|---|---|
CreateMessageTypePrefix | ||
Dispose | ||
Error |
If a fatal exception happened this message is logged. Often the App has to quit afterward.
View code on GitHub | |
Info |
Lowest available log level for notifications like a successful operation or debug output.
View code on GitHub | |
Warning(Exception) |
If something bad happened and we caught a non fatal exception this message is logged.
View code on GitHub | |
Warning(String) |
If something bad happened but we can continue this type of message is logged.
View code on GitHub | |
Write |
Properties
Name | Description | |
---|---|---|
LastMessage | ||
NumberOfRepeatedMessagesIgnored |
Remarks
Examples
[Test] public void LogInfoMessage() { using (var logger = new MockLogger()) { Assert.IsEmpty(logger.LastMessage); Logger.Info("Hello"); Assert.AreEqual("Hello", logger.LastMessage); Assert.AreEqual(0, logger.NumberOfRepeatedMessagesIgnored); } }
[Test] public void LogSameMessageMultipleTimes() { using (var logger = new MockLogger()) { Logger.Info("Hello"); Logger.Info("Hello"); Assert.AreEqual(1, logger.NumberOfRepeatedMessagesIgnored); } }
[Test] public void LogWarning() { using (var logger = new MockLogger()) { Logger.Warning("Ohoh"); Assert.AreEqual("Ohoh", logger.LastMessage); Logger.Warning(new NullReferenceException()); Assert.IsTrue(logger.LastMessage.Contains("NullReferenceException")); } }
See Also