Logger ClassDelta Engine Documentation
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

System Object
  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

public abstract class Logger : IDisposable

The Logger type exposes the following members.

Constructors

  NameDescription
Protected methodLogger
Initializes a new instance of the Logger class
Top
Methods

  NameDescription
Protected methodCreateMessageTypePrefix
Public methodDispose
Public methodStatic memberError
If a fatal exception happened this message is logged. Often the App has to quit afterward. View code on GitHub
Public methodStatic memberInfo
Lowest available log level for notifications like a successful operation or debug output. View code on GitHub
Public methodStatic memberWarning(Exception)
If something bad happened and we caught a non fatal exception this message is logged. View code on GitHub
Public methodStatic memberWarning(String)
If something bad happened but we can continue this type of message is logged. View code on GitHub
Public methodWrite
Top
Properties

  NameDescription
Public propertyLastMessage
Public propertyNumberOfRepeatedMessagesIgnored
Top
Remarks

Tests: DeltaEngine.Tests.Core.LoggerTests
Examples

7 unit tests call DeltaEngine.Core.Logger
[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