-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Use jcabi-log to reduce startup time #3015
Conversation
4045be0
to
ab9a710
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The jcabi log framework is new to me and I have nothing against reworking our current logging implementation. As far as I can see it saves us the declaration of the static variable, with is clearly a benefit. But does it actually improve something performance-wise? Because as far as I understand, it's just a wrapper for slf4j and then I don't see why it should be faster. But anyway, the readability improvement is probably worth it already.
Nevertheless, you have a few failing tests here. Do these fail because of logging? They need to succeed before we can merge.
Finally, when I look at the blog post where the framework is introduced: http://www.yegor256.com/2014/05/23/avoid-java-static-logger.html and scroll to the comments, I can find one by our good friend @simonharrer, who recommends this: http://www.tinylog.org/ I can't really find a comparison between jcabi and tinylog, but if I understand it correctly then tinylog will use just one logger and nothing class-based (which seems to be something that we want).
TL&DR: I want to know how this affects performance. Otherwise, fix the failing tests and then it's mergeable.
… of LOGGER.debug(...)
@lenhard You are right, the logging of exceptions changed (not that obviously documented - see jcabi/jcabi-log#68).
becomes
I began to rewrite our code, but I am unsure whether we really want that. Maybe we should write our own static log methods which check whether the last parameter is instance of Throwable, add |
3% improvement is an improvement, so we should go for it :) Regarding the exception: I think the way you suggest is the right one. You should write a wrapper class, say |
Yes, but instead of checking explicitly for a throwable, just create one wrapper method overlaod which excepts an Throwable as second argument. |
# Conflicts: # src/main/java/org/jabref/cli/ArgumentProcessor.java # src/main/java/org/jabref/gui/preftabs/PreviewPrefsTab.java
Done. See org.jabref.Logger. We still (?) have many classes with static methods. 0c0d26b#diff-f64d223f20f6b0e53b00c8dbd2be2ce1R62 I cannot fix that, but just ignore them in the ArchitectureTests. |
/** begin: direct pass-through **/ | ||
|
||
public static void trace(final Object source, final String msg) { | ||
com.jcabi.log.Logger.trace(source, msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you import this package or will it provide conflicsts with the local class named Logger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there would be conflicts.
Not sure if changing the interface of such a well-known functionality like logging is really the way to go. Don't you think this will lead to fragmented code as not everyone is used to it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace the array concat with Guava, the rest LGTM
src/main/java/org/jabref/Logger.java
Outdated
* Merges args and e together into an array starting with args | ||
*/ | ||
private static Object[] merge(Object[] args, Throwable e) { | ||
final int length = args.length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guava has a method for Array concat:
https://google.github.io/guava/releases/19.0/api/docs/com/google/common/collect/ObjectArrays.html#concat(T%5B%5D,%20T%5B%5D,%20java.lang.Class)
docs/adr/index.md
Outdated
@@ -0,0 +1,7 @@ | |||
# Architectural Decision Records | |||
|
|||
This lists the architectural decisions for Eclipse Winery™ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stuff from Winery....
I agree that this is uncommon. However, I think (i) it is more convenient to work without Logger factory, if one wants "gschwind mal was loggen". (ii) We have the architecture test in place complaining if someone uses apache commons logging 😇 . |
Why is there a problem with using the Logger in static methods? Because you need to provide an instance as the source of the message? If that's the case, why don't you just do something like this: The style of logging should be the same everywhere, in static and non-static methods. If we can't find a uniform way, logging will just degrade over time and we end up with a mess. |
jcabi-log needs In case we don't want to have this feature, I can rewrite the layer so that |
Hm, how about at least adding a few methods to the current solution that does not require |
I'd still favor keeping the current logging. I don't see too much improvements and a few problems with the new solution. |
Logger.debug(CurrentClass.class, ...) works. I also like the fact, I can
just do Logger.debug(this, ...) in a class where there currently is no
logger... Maybe an issue for the devcall... 🕺
Am 21.07.2017 12:47 schrieb "Stefan Kolb" <notifications@github.com>:
… I'd still favor keeping the current logging. I don't see too much
improvements and a few problems with the new solution.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3015 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABTafgJ83J1qffkWA-1V4--CuNb6m-IWks5sQIGsgaJpZM4OY3eF>
.
|
We do NOT want to change the usual way of doing logging for just saving some seconds at the startup time. |
If I redid this, I would give tinylog a try. |
This implements #2966 (comment):
#3017 is also included here, because of
net.corda:jfx
depends onorg.slf4j:jcl-over-slf4j
, but we want to pipe slf4j to jcl.@tobiasdiez Could you check the startup time?
gradle localizationUpdate
?