ConsoleLogger ClassDelta Engine Documentation
Very simple logger just spaming out all log events into the console. Used by default. View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Core Logger
    DeltaEngine.Core ConsoleLogger

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

public class ConsoleLogger : Logger

The ConsoleLogger type exposes the following members.

Constructors

  NameDescription
Public methodConsoleLogger
Initializes a new instance of the ConsoleLogger class
Top
Methods

  NameDescription
Protected methodCreateMessageTypePrefix (Inherited from Logger.)
Public methodDispose
Releases all resources used by the ConsoleLogger
(Overrides Logger Dispose .)
Public methodWrite
Write all messages to the console, but limit to 100 per second and 10 in debug mode as the console is very slow and will cause the app to freeze if too many messages are processed. View code on GitHub
(Overrides Logger Write(Logger MessageType, String).)
Top
Properties

  NameDescription
Public propertyDoNotSkipMessagesIfTooManyAreWrittenEachSecond
Public propertyLastMessage (Inherited from Logger.)
Public propertyNumberOfRepeatedMessagesIgnored (Inherited from Logger.)
Top
Remarks

Tests: DeltaEngine.Tests.Core.ConsoleLoggerTests
Examples

5 unit tests call DeltaEngine.Core.ConsoleLogger
[Test]
public void WriteInfo()
{
    using (var logger = new ConsoleLogger())
    {
        Assert.AreEqual("", console.ToString());
        logger.Write(Logger.MessageType.Info, "Hello");
        Assert.IsTrue(console.ToString().Contains("Hello"), console.ToString());
    }
}
[Test]
public void LogWarning()
{
    using (var logger = new ConsoleLogger())
    {
        Assert.AreEqual("", console.ToString());
        logger.Write(Logger.MessageType.Warning, "Ohoh");
        Assert.IsTrue(console.ToString().Contains("Warning: Ohoh"), console.ToString());
        logger.Write(Logger.MessageType.Warning, new NullReferenceException().ToString());
        Assert.IsTrue(console.ToString().Contains("NullReferenceException"), console.ToString());
    }
}
[Test]
public void LogError()
{
    using (var logger = new ConsoleLogger())
    {
        Assert.AreEqual("", console.ToString());
        logger.Write(Logger.MessageType.Error, new NotSupportedException().ToString());
        Assert.IsTrue(console.ToString().Contains("NotSupportedException"), console.ToString());
    }
}
See Also