]> git.ipfire.org Git - thirdparty/gcc.git/blob - libphobos/src/std/experimental/logger/nulllogger.d
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
[thirdparty/gcc.git] / libphobos / src / std / experimental / logger / nulllogger.d
1 // Written in the D programming language.
2 /**
3 Source: $(PHOBOSSRC std/experimental/logger/nulllogger.d)
4 */
5 module std.experimental.logger.nulllogger;
6
7 import std.experimental.logger.core;
8
9 /** The `NullLogger` will not process any log messages.
10
11 In case of a log message with `LogLevel.fatal` nothing will happen.
12 */
13 class NullLogger : Logger
14 {
15 /** The default constructor for the `NullLogger`.
16
17 Independent of the parameter this Logger will never log a message.
18
19 Params:
20 lv = The `LogLevel` for the `NullLogger`. By default the `LogLevel`
21 for `NullLogger` is `LogLevel.all`.
22 */
23 this(const LogLevel lv = LogLevel.all) @safe
24 {
25 super(lv);
26 this.fatalHandler = delegate() {};
27 }
28
29 override protected void writeLogMsg(ref LogEntry payload) @safe @nogc
30 {
31 }
32 }
33
34 ///
35 @safe unittest
36 {
37 import std.experimental.logger.core : LogLevel;
38 auto nl1 = new NullLogger(LogLevel.all);
39 nl1.info("You will never read this.");
40 nl1.fatal("You will never read this, either and it will not throw");
41 }