TextLogger ClassDelta Engine Documentation
Simply appends log messages to a public property. View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Core Logger
    DeltaEngine.Logging TextLogger

Namespace: DeltaEngine.Logging
Assembly: DeltaEngine.Logging (in DeltaEngine.Logging.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class TextLogger : Logger

The TextLogger type exposes the following members.

Constructors

  NameDescription
Public methodTextLogger
Initializes a new instance of the TextLogger class
Top
Methods

  NameDescription
Protected methodCreateMessageTypePrefix (Inherited from Logger.)
Public methodDispose (Inherited from Logger.)
Public methodWrite (Overrides Logger Write(Logger MessageType, String).)
Top
Properties

  NameDescription
Public propertyLastMessage (Inherited from Logger.)
Public propertyLog
Public propertyNumberOfRepeatedMessagesIgnored (Inherited from Logger.)
Top
Events

  NameDescription
Public eventNewLogMessage
Top
Remarks

Tests: DeltaEngine.Logging.Tests.TextLoggerTests
Examples

3 unit tests call DeltaEngine.Logging.TextLogger
[Test]
public void LogInfo()
{
    using (var logger = new TextLogger())
    {
        bool newLogMessageArrived = false;
        logger.NewLogMessage += () => newLogMessageArrived = true;
        Assert.IsFalse(newLogMessageArrived);
        Logger.Info("Message");
        Assert.IsTrue(newLogMessageArrived);
        Assert.IsTrue(logger.Log.EndsWith("Message"), logger.Log);
    }
}
[Test]
public void LogWarning()
{
    using (var logger = new TextLogger())
    {
        Logger.Warning("Warning");
        Logger.Warning(new WarningException(""));
        Assert.IsTrue(logger.Log.EndsWith(typeof(WarningException).ToString()), logger.Log);
    }
}
[Test]
public void LogError()
{
    using (var logger = new TextLogger())
    {
        Logger.Error(new TestError(""));
        Assert.IsTrue(logger.Log.Contains(typeof(TestError).ToString()), logger.Log);
    }
}
See Also