You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Internally we heavily use SLF4J for logging in our classes.
We would like to have a check to canonicalize the usage of such loggers.
For that reason we would like a check that looks at the following things:
Is the variable declared with the modifiers private static final?
Is the variable name of the logger LOG?
Is the correct class name passed to LoggerFactory#getLogger?
For interfaces we have to make an exception when it comes to the private static final, as in interfaces this is not an option.
As raised by @mlrprananta himself, we could parameterize the variable name of the logger. Perhaps we can add an option that people can override the allowed variable name of the logger via the ErrorProneFlags.
For this check we don't need to look at the line on which the logger is defined, we will do that in a different check.
Additional context
This project has some related checks KengoTODA/errorprone-slf4j.
However, we want a check that is specific to our internal standards. Additionlly, in EPS we have our own best practices that we want to use for the code of this check.
Later, we might want to add more features to this check. This would be a good first version 😄.
The text was updated successfully, but these errors were encountered:
I wonder whether we should default to a more permissible name pattern (e.g. LOG(GER)?), and then internally fix that to just LOG. This may ease external adoption. (Perhaps using CodeQL we can find which variants are most common in open source software 🤔.)
Hey @rickie, I won't have much time to look into this coming weeks, but I'd like to take a look at this later again (I unassigned myself for now, if someone else wants to pick it up that's also fine)
Problem
Internally we heavily use SLF4J for logging in our classes.
We would like to have a check to canonicalize the usage of such loggers.
For that reason we would like a check that looks at the following things:
private static final
?LOG
?LoggerFactory#getLogger
?Description of the proposed new feature
I would like to rewrite the following code:
to:
Considerations
For interfaces we have to make an exception when it comes to the
private static final
, as in interfaces this is not an option.As raised by @mlrprananta himself, we could parameterize the variable name of the logger. Perhaps we can add an option that people can override the allowed variable name of the logger via the
ErrorProneFlags
.For this check we don't need to look at the line on which the logger is defined, we will do that in a different check.
Additional context
This project has some related checks KengoTODA/errorprone-slf4j.
However, we want a check that is specific to our internal standards. Additionlly, in EPS we have our own best practices that we want to use for the code of this check.
Later, we might want to add more features to this check. This would be a good first version 😄.
The text was updated successfully, but these errors were encountered: