A structured event logger for Fluent
struct Event
{
string text = "This is D";
long id = 0;
}
// ...
import fluent.logger;
// Create a configuration
FluentLogger.Configuration conf;
// Create a logger with tag prefix and configuration
auto logger = new FluentLogger("app", conf);
// Write Event object with "test" tag to Fluentd
logger.post("test", Event());
// Disconnect and perform cleanup
logger.close(); // Or destroy(logger);
In this result, Fluentd accepts {"text":"This is D","id":0}
at "app.test" tag.
Currently, FluentLogger is not marked as shared
.
So, if you share a logger object accross threads, please use __gshared
.
The library: dub build
Documentation: dub build --build=docs
Examples:
Single-threaded: dub build --config=post-example
Multi-threaded: dub build --config=post-mt-example
- std.log support after Phobos accepts std.log
- Add some qualifiers (@safe, nothrow, shared, etc..)
- Windows support
-
Fluentd official site
-
Github repository
Author | Masahiro Nakagawa |
Copyright | Copyright (c) 2012- Masahiro Nakagawa |
License | Apache License, Version 2.0 |