- Last few docs added
This commit is contained in:
Tristan B. Velloza Kildaire 2024-04-09 19:04:31 +02:00
parent 66adb8f700
commit 9d8f7af4a3
1 changed files with 65 additions and 5 deletions

View File

@ -67,6 +67,11 @@ public interface Handler
public void handle(Message message); public void handle(Message message);
} }
/**
* Defines the base logger
* and functionality associated
* with it
*/
public abstract class Logger public abstract class Logger
{ {
private SList!(Transform) transforms; private SList!(Transform) transforms;
@ -74,12 +79,22 @@ public abstract class Logger
private SList!(Handler) handlers; private SList!(Handler) handlers;
private Mutex lock; // Lock for attached handlers, filters and transforms private Mutex lock; // Lock for attached handlers, filters and transforms
/**
* Constructs a new logger
*/
this() this()
{ {
this.lock = new Mutex(); this.lock = new Mutex();
} }
// TODO: Handle duplicate? // TODO: Handle duplicate?
/**
* Adds the given transform
*
* Params:
* transform = the transform
* to add
*/
public final void addTransform(Transform transform) public final void addTransform(Transform transform)
{ {
scope(exit) scope(exit)
@ -93,6 +108,13 @@ public abstract class Logger
} }
// TODO: Hanmdle not found explicitly? // TODO: Hanmdle not found explicitly?
/**
* Removes the given transform
*
* Params:
* transform = the transform
* to remove
*/
public final void removeTransform(Transform transform) public final void removeTransform(Transform transform)
{ {
scope(exit) scope(exit)
@ -106,6 +128,14 @@ public abstract class Logger
} }
// TODO: Handle duplicate? // TODO: Handle duplicate?
/**
* Adds the given filter
*
* Params:
* filter = the filter
* to add
*/
public final void addFilter(Filter filter) public final void addFilter(Filter filter)
{ {
scope(exit) scope(exit)
@ -119,6 +149,14 @@ public abstract class Logger
} }
// TODO: Hanmdle not found explicitly? // TODO: Hanmdle not found explicitly?
/**
* Removes the given filter
*
* Params:
* filter = the filter
* to remove
*/
public final void removeFilter(Filter filter) public final void removeFilter(Filter filter)
{ {
scope(exit) scope(exit)
@ -132,6 +170,14 @@ public abstract class Logger
} }
// TODO: Handle duplicate? // TODO: Handle duplicate?
/**
* Adds the given handler
*
* Params:
* handler = the handler
* to add
*/
public final void addHandler(Handler handler) public final void addHandler(Handler handler)
{ {
scope(exit) scope(exit)
@ -145,6 +191,14 @@ public abstract class Logger
} }
// TODO: Hanmdle not found explicitly? // TODO: Hanmdle not found explicitly?
/**
* Removes the given handler
*
* Params:
* handler = the handler
* to remove
*/
public final void removeHandler(Handler handler) public final void removeHandler(Handler handler)
{ {
scope(exit) scope(exit)
@ -157,11 +211,17 @@ public abstract class Logger
this.handlers.linearRemoveElement(handler); this.handlers.linearRemoveElement(handler);
} }
// Logs an actual message /**
// * Logs the provided message by processing
// This first passes it over all filters * it through all the filters, and if
// then to a transform and then copies * the verdict is `true` then transforms
// to each handler * the message via all transformers
* and finally dispatches said message
* to all attached handlers
*
* Params:
* message = the message
*/
public final void log(Message message) public final void log(Message message)
{ {
scope(exit) scope(exit)