From 39c2fe78fd6d5a504ee86b438776b9f0621c1271 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Tue, 9 Apr 2024 08:44:30 +0200 Subject: [PATCH] BasicLogger - Now stores current level in a filter of its own - The `LevelFilter` is attached to the `BasicLogger` on construction LevelFilter - Now use a `Level*` rather --- source/dlog/nu/basic.d | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/source/dlog/nu/basic.d b/source/dlog/nu/basic.d index 92413a6..df17d67 100644 --- a/source/dlog/nu/basic.d +++ b/source/dlog/nu/basic.d @@ -57,13 +57,13 @@ public enum Level DEBUG } -public class LevelFilter : Filter +private class LevelFilter : Filter { - private Level curLevel; + private Level* level; - this() + this(Level* level) { - + this.level = level; } public bool filter(Message message) @@ -72,7 +72,7 @@ public class LevelFilter : Filter BasicMessage bmesg = cast(BasicMessage)message; if(bmesg) { - return bmesg.getLevel() <= this.curLevel; + return bmesg.getLevel() <= *this.level; } return false; @@ -85,6 +85,14 @@ public class BasicLogger : Logger this() { + // Attach a new level-filter + // with access to our current + // level + addFilter(new LevelFilter(&level)); + } + public final void setLevel(Level level) + { + this.level = level; } } \ No newline at end of file