Repository navigation
Replies: 3 comments
|
Tagging @pmwmedia to keep me honest and for corrections: Yes I saw tinylog a long time ago as 1.0 and I forgot to add it to the list. Great library! For now the major difference is tinylog like its name focuses on being "tiny" and rainbowgum is focused on being "small" in core and modular as well as exploiting as much of modern JDK offerings. Rainbow Gum also focuses on having faster initialization, strong programmatic options for configuration and doing various optimizations because of invariants as well as static code generation (annotation processor). For example the programmatic configuration for Tinylog is filling a Tinylog is less componetized and like logback prefers inheritance and large classes to do multiple things which is the case with its Rainbow Gum's builders and composition over inheritance come at a cost of more classes and is most likely why its core is bigger than all of Tinylog (which massive kudos for tinylog on that). Just to give an example. Say there is a composite like component that has a list of tinylog writers. The natural solution would be to have that as one class that always iterates over that list. Rainbow Gum does not do that. It has "single" version that will not iterate over a list and this is resolved through static factory methods. Again this is why rainbow gum is bigger because it has more implementations of these components where something like logback and tinylog would only have one implementation and rely on the JIT to make the eventual optimization. An example of eager optimization in terms of loggers is best to use tinylogs custom logging api example: https://tinylog.org/v2/extending/#custom-logging-api Tinylog recommends this: package org.tinylog.example;
import org.tinylog.Level;
import org.tinylog.provider.LoggingProvider;
import org.tinylog.provider.ProviderRegistry;
public class MyLogger {
private static final LoggingProvider provider = ProviderRegistry.getLoggingProvider();
private static final int minimumLevel = provider.getMinimumLevel(null).ordinal();
private static final boolean infoEnabled = minimumLevel <= Level.INFO.ordinal();
private static final boolean errorEnabled = minimumLevel <= Level.ERROR.ordinal();
public static void info(String message) {
if (infoEnabled) {
provider.log(2, null, Level.INFO, null, null, message);
}
}
public static void error(Throwable exception) {
if (errorEnabled) {
provider.log(2, null, Level.ERROR, exception, null, null);
}
}
}Rainbow Gum on the other hand literally has a class for each level such that the error logger is literally: public static void info(String message) {
}
public static void error(Throwable exception) {
provider.log(2, null, Level.ERROR, exception, null, null);
}While the above doesn't actual exist in Rainbow Gum because static method logging is not common so its best to compare the SLF4J logger implemntations: That is compare: Another example of this eager optimization is that Tinylogger and others only have one implementation of their "event". Rainbow Gum has several based on static factories and this to reduce unnecessary memory usage as there is no way events are going to be EA (escape analysis). That being said its unlike Rainbow Gum will ever add line number and method name to events as more often than not people forget to turn that off in production and in dev people can and should just use a debugger. Tinylog I think uses a fair amount of Tinylog custom service loader approach (it allows more than no-arg constructors) while novel I'm not sure how well it works in a modular environment. I assume it would but not sure. That is I'm not sure if the Speaking of ServiceLoader TinyLog on its next version should make a single SPI interface so that it only makes once ServiceLoader call instead of a call for each type of component. For example there is a One of my favorite things in the Tinylog doc is how they format the Anyway its a great library and its why I did such an in depth analysis. |
I must be doing something wrong. There is no way Rainbow Gum is that much faster. I kept think it was slower because it is "s/op". |
|
@agentgt Thank you for the quick and impressive action taken. I wonder whether some of the result can be included at https://github.com/jstachio/rainbowgum?tab=readme-ov-file#comparison-to-other-frameworks? |
Uh oh!
There was an error while loading. Please reload this page.
Thank you for spending energy to a modern logging framework.
At https://github.com/jstachio/rainbowgum?tab=readme-ov-file#comparison-to-other-frameworks, I miss a comparison to tinylog2, which also has similar goals (IMHO).
All reactions