2 ms·
Huh. I'll have to try that. Thanks. My solution was to flip the problem, making a separate logger instance for each log level. So something like Logger warn
by specialist 9y ago
Huh. I'll have to try that. Thanks.
My solution was to flip the problem, making a separate logger instance for each log level. So something like
Logger warn = Logger.factory(Level.WARN);
warn.log( "message" );
If warn is disabled, factory returns a NullObject (do nothing) logger.
(My actual implementation had one level of indirection, so logs levels could be updated at runtime.)
Then I got nutty optimizing printf, doing JIT class generation per template... But that's another story.
TL;DR: Logging in Java drives me nuts, so I made my own.
- _old_dude_ 9y agoDid you take a look to java.lang.invoke.StringConcatFactory, it does more or less what you want using method handles instead of bytecode generation ?
- specialist 9y agoThanks for the tip. Will check it out. I'll be happy if it moots my hackery.