Singleton for simple logging https://code.dlang.org/packages/singlog
Go to file
Alexander Zhirov f87ecc6d7e Log of debug messages 2023-06-01 17:31:39 +03:00
source Log of debug messages 2023-06-01 17:31:39 +03:00
tests release v0.3.0 2023-04-28 11:32:15 +03:00
.gitignore first test 2023-04-27 21:08:12 +03:00
CHANGELOG.md Log of debug messages 2023-06-01 17:31:39 +03:00
LICENSE v0.1.0 2023-03-23 12:20:46 +03:00
README.md Log of debug messages 2023-06-01 17:31:39 +03:00
dub.json release v0.3.0 2023-04-28 11:32:15 +03:00
dub.selections.json v0.1.0 2023-03-23 12:20:46 +03:00
dub.settings.json v0.1.0 2023-03-23 12:20:46 +03:00
singlog.png release v0.3.0 2023-04-28 11:32:15 +03:00

README.md

singlog

license main githab dub linux windows

Singleton for simple logging

Basic Usage

import singlog;

void main(string[] argv) {
    log.output(log.SYSLOG | log.STDOUT | log.FILE)  // write to syslog, standard output stream and file
        .name(argv[0])                              // program name as an identifier (for Windows OS)
        .level(log.DEBUGGING)                       // logging level
        .file("./test.log");                        // the path to the log file

    log.e("This is an error message");
    log.error("And this is also an error message");
    log.w("This is a warning message");
    log.i("This is an information message");
}

Examples

Setting the name of the logged program (it matters for Windows OS):

log.name("My program");

Setting the error output level:

log.level(log.DEBUG);
log.level(log.ALERT);
log.level(log.CRIT);
log.level(log.ERR);
log.level(log.WARNING);
log.level(log.NOTICE);
log.level(log.INFO);

Assigning a target output:

log.output(log.SYSLOG);
log.output(log.STDOUT);

Setup and allowing writing to a file:

log.output(log.FILE);
log.file("./file.log");

Output of messages to the log:

log.a("Alert message")          =>    log.alert("Alert message");
log.c("Critical message")       =>    log.critical("Critical message");
log.e("Error message")          =>    log.error("Error message");
log.w("Warning message")        =>    log.warning("Warning message");
log.n("Notice message")         =>    log.notice("Notice message");
log.i("Information message")    =>    log.information("Information message");
log.d("Debugging message")      =>    log.debugging("Debugging message");

DUB

Add a dependency on "singlog": "~>0.3.1".