1 /// 2 module std.experimental.logger.nulllogger; 3 4 import std.experimental.logger.core; 5 6 /** The $(D NullLogger) will not process any log messages. 7 8 In case of a log message with $(D LogLevel.fatal) nothing will happen. 9 */ 10 class NullLogger : Logger 11 { 12 /** The default constructor for the $(D NullLogger). 13 14 Independent of the parameter this Logger will never log a message. 15 16 Params: 17 lv = The $(D LogLevel) for the $(D NullLogger). By default the $(D LogLevel) 18 for $(D NullLogger) is $(D LogLevel.all). 19 */ 20 this(const LogLevel lv = LogLevel.all) @safe 21 { 22 super(lv); 23 this.fatalHandler = delegate() {}; 24 } 25 26 override protected void writeLogMsg(ref LogEntry payload) @safe @nogc 27 { 28 } 29 } 30 31 /// 32 @safe unittest 33 { 34 import std.experimental.logger.nulllogger : LogLevel; 35 36 auto nl1 = new NullLogger(LogLevel.all); 37 nl1.info("You will never read this."); 38 nl1.fatal("You will never read this, either and it will not throw"); 39 } 40