slf4d 0.0.4
Simple Logging Facade For D
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
SLF4D
Simple Logging Facade For D, inspired by SLF4J.
import slf4d;
void main() {
auto log = getLogger();
log.info("Hello world!");
}
This library provides a common framework for detailed application logging, while allowing end users to use a logging provider of their choice. SLF4D gives you a basic Logger
that exposes various log
methods, and a logging provider will handle log messages generated by your application in any way it likes.
In short, with SLF4D, you can:
- Obtain a
Logger
viagetLogger()
. - Produce log messages via the various log methods on
Logger
. - Configure a custom logging provider via
configureLoggingProvider()
.
Using SLF4D in your Application
All you need to do is call configureLoggingProvider()
when your application starts, to set the logging provider to use.
module app_main;
import slf4d;
import some_slf4d_provider : CustomProvider;
void main() {
configureLoggingProvider(new CustomProvider());
}
Then, in any module of your application, you can simply call getLogger()
to get a Logger to use.
module some_other_module;
import slf4d;
void doStuff() {
auto log = getLogger();
// Do things...
log.info("This is my log message.");
}
Default Provider
In case you just want to get started using SLF4D right away, we've included the slf4d.default_provider
module which defines a basic provider that just logs simple messages to stdout and stderr. In this case, you can go ahead and call getLogger()
without configuring the logging provider.
Making an SLF4D-Compatible Provider
To create a logging provider, simply implement the LoggingProvider
interface defined in slf4d.provider
. Note that your logging factory and handler should be shared
, that is, they will be shared among all threads of an application which uses your provider.
- 0.0.4 released a year ago
- andrewlalis/slf4d
- MIT
- Copyright © 2023, Andrew Lalis
- Authors:
- Dependencies:
- none
- Versions:
-
3.0.1 2024-Apr-03 3.0.0 2024-Jan-27 2.4.3 2023-Aug-24 2.4.2 2023-Jul-17 2.4.1 2023-Jul-02 - Download Stats:
-
-
8 downloads today
-
86 downloads this week
-
458 downloads this month
-
22418 downloads total
-
- Score:
- 3.4
- Short URL:
- slf4d.dub.pm