[slf4j-user] FYI - structured logging wrapper for SLF4J
Jordan Zimmerman
jordan at jordanzimmerman.com
Tue Oct 1 22:15:44 CEST 2019
> because then you can use that S.fluent().call().chain() code in other contexts
I see. You can actually decouple, though it might need a bit more work depending on what you need. For example, the lambda can be defined independently. E.g.
Statement<Schema> s = s -> s.name(foo).age(bar);
This statement can then be re-used and even extended. There's an example here - https://github.com/Randgalt/maple/blob/master/maple-examples/src/main/java/com/myco/app/request/UpdateService.java <https://github.com/Randgalt/maple/blob/master/maple-examples/src/main/java/com/myco/app/request/UpdateService.java>.
Maple has a bunch on internal utils that could be useful outside of logging. For example, you can convert a statement lambda into a list of Names/Values via the MapleSpi factory. E.g.
// save this meta instance somewhere
var metaIInstance = MapleSpi.instance().generate(Schema.class);
// convert a statement into names/values
var instance = metaInstance.newSchemaInstance();
s.handle(instance);
var namesValues = metaIInstance.toNamesValues(instance);
If this became a desired idiom I could make a little utility for this bit.
> OT3H I may be moving towards log4j2 in the next months anyway
FWIW - I wrote Maple in an implementation neutral way. It would be very easy to add a direct Log4J2 backend for it. Just a few classes to implement.
-JZ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/slf4j-user/attachments/20191001/6bd302a1/attachment.html>
More information about the slf4j-user
mailing list