module app;

import slf4d;

void main() {
	// Log some messages.
	info("This is an info message.");
	infoF!"An info message with some data: %d"(42);
	warn("A warning message.");
	error("An error message! Oh no!");
	import std.math : PI;
	errorF!"Another error message with some pi: %.6f"(PI);

	// By default, only INFO or higher messages will be logged.
	trace("This is a trace message. It won't show up by default unless the logger's level is set to TRACE.");
	debug_("Same with debug. Note that the method is \"debug_\", because \"debug\" is a D keyword.");
	
	// Because we are using the default provider, its LoggerFactory supports setting the log level.
	import slf4d.default_provider : DefaultLoggerFactory;
	DefaultLoggerFactory factory = cast(DefaultLoggerFactory) getLoggerFactory();
	factory.setRootLevel(Levels.TRACE);

	trace("This trace message should show up.");
	debug_("This debug message should show up.");
	debugF!"This debug message will show up too! %s"("Test");

	// You can manually set the logger's name when you get it.
	auto otherLog = getLogger("custom-logger-name");
	otherLog.info("This message was generated by a logger with a custom name.");

	// You can also log any set of arbitrary attributes as an associative array of strings.
	info("Here are some attributes.", null, [
		"key1": "value1",
		"key2": "42",
		"key3": "3.14",
		"key4": "true"
	]);
}