Skip to content

Add @Deprecated catch for logging assuming slf4j convention#44

Merged
drcrallen merged 1 commit intomasterfrom
saferLoggingOfCriticalErrors
Sep 7, 2016
Merged

Add @Deprecated catch for logging assuming slf4j convention#44
drcrallen merged 1 commit intomasterfrom
saferLoggingOfCriticalErrors

Conversation

@drcrallen
Copy link
Copy Markdown
Contributor

It is very easy for people unfamiliar with the logging conventions used here to swap these arguments, sometimes not yielding the desired information. This PR shows that methodology as deprecated and hopefully helps track down erroneous logging usages.

This might potentially change logging if someone had done the following:

LOG.error("found an error: %s", someException);

The fix would be to do something like

LOG.error("found an error: %s", someException.getMessage());

final Throwable throwable = new Throwable();
log.error("foo", throwable);
log.warn("foo", throwable);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you are expecting IDE to flag these as deprecated. but since there are no asserts, its difficult for someone to understand what is being "tested" here. can you add comment telling why this test needs to exist or may be remove it since it can't really "fail" whether or not the thing you expected works or not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sure

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@nishantmonu51
Copy link
Copy Markdown
Contributor

👍

@drcrallen drcrallen force-pushed the saferLoggingOfCriticalErrors branch from 998a13b to b80faf4 Compare March 16, 2016 19:29
@drcrallen
Copy link
Copy Markdown
Contributor Author

@himanshug any other comments?

@leventov
Copy link
Copy Markdown
Contributor

leventov commented Sep 7, 2016

+1. Don't see a better way to protect from this or exclude this situation.

@drcrallen drcrallen merged commit fe9eefb into master Sep 7, 2016
@drcrallen drcrallen deleted the saferLoggingOfCriticalErrors branch September 7, 2016 21:34
@leventov
Copy link
Copy Markdown
Contributor

leventov commented Sep 7, 2016

However seems that it uses inconsistent formatting.. { no the same line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants