From b13621fd82c437a27bbad60cb64d53a0a258e27a Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Tue, 9 Apr 2024 08:34:55 +0200 Subject: [PATCH] Logger - You can now add and remove filters and handlers --- source/dlog/nu/core.d | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/source/dlog/nu/core.d b/source/dlog/nu/core.d index 5de7e90..e89f3bf 100644 --- a/source/dlog/nu/core.d +++ b/source/dlog/nu/core.d @@ -72,6 +72,58 @@ public abstract class Logger this.transforms.linearRemoveElement(transform); } + // TODO: Handle duplicate? + public final void addFilter(Filter filter) + { + scope(exit) + { + this.lock.unlock(); + } + + this.lock.lock(); + + this.filters.insertAfter(this.filters[], filter); + } + + // TODO: Hanmdle not found explicitly? + public final void removeFilter(Filter filter) + { + scope(exit) + { + this.lock.unlock(); + } + + this.lock.lock(); + + this.filters.linearRemoveElement(filter); + } + + // TODO: Handle duplicate? + public final void addHandler(Handler handler) + { + scope(exit) + { + this.lock.unlock(); + } + + this.lock.lock(); + + this.handlers.insertAfter(this.handlers[], handler); + } + + // TODO: Hanmdle not found explicitly? + public final void removeHandler(Handler handler) + { + scope(exit) + { + this.lock.unlock(); + } + + this.lock.lock(); + + this.handlers.linearRemoveElement(handler); + } + // Logs an actual message // // This first passes it over all filters