[
https://issues.apache.org/jira/browse/HCATALOG-68?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13226564#comment-13226564
]
Sushanth Sowmyan edited comment on HCATALOG-68 at 3/9/12 10:49 PM:
-------------------------------------------------------------------
#1 : No, the idea was to use commons logging. :) I think this line item was to
use log4j consistently - the goal there was to erradicate any
System.out/System.err debugs and to convert them to commons logging.
#2 : Yes, the idea was to move logging functions in HCatUtil out to a separate
LogUtil class, for eg., and also, preferrably, to get rid of the need to
declare a LOG variable in each class - the idea was to simply look at the
caller of the log function to determine the logger in a centralized place, and
to use that for logging. i.e., in existing functions, instead of declaring a
LOG variable and then running LOG.warn() or LOG.debug(), we'd simply call
LogUtil.warn(), and LogUtil.warn() would automatically do the needful by
detecting its caller.
#3 : I don't consider this terribly important right now, and I don't entirely
remember why I had this in, but I think the idea was this:
Consider a log statement like this:
{code:java}
LOG.debug(
mySchema.toString()
+ " : blah blah blah " + anotherSchema.toString()
+ "bloo blah blah" + HCatSchemaUtil.getSchemaFromTypeInfo(blahTypeInfo));
{code}
It's entirely likely that the debug level for the caller is not set, and thus,
log4j would not log that line. So, doing something like this instead :
{code:java}
if (LOG.isDebugEnabled()){
LOG.debug(
mySchema.toString()
+ " : blah blah blah " + anotherSchema.toString()
+ "bloo blah blah" +
HCatSchemaUtil.getSchemaFromTypeInfo(blahTypeInfo));
}
{code}
Then the execution is identical, except for the evaluation of the call
parameters as long as the parameters don't have any side-effects, and is much
faster in cases where calculating the item to be logged would be expensive. So,
the goal was to code-scrub to find such instances, and replace where possible.
was (Author: sushanth):
#1 : No, the idea was to use commons logging that uses log4j consistently -
the goal there was to erradicate any System.out/System.err debugs and to
convert them to commons logging.
#2 : Yes, the idea was to move logging functions in HCatUtil out to a separate
LogUtil class, for eg., and also, preferrably, to get rid of the need to
declare a LOG variable in each class - the idea was to simply look at the
caller of the log function to determine the logger in a centralized place, and
to use that for logging. i.e., in existing functions, instead of declaring a
LOG variable and then running LOG.warn() or LOG.debug(), we'd simply call
LogUtil.warn(), and LogUtil.warn() would automatically do the needful by
detecting its caller.
#3 : I don't consider this terribly important right now, and I don't entirely
remember why I had this in, but I think the idea was this:
Consider a log statement like this:
{code:java}
LOG.debug(
mySchema.toString()
+ " : blah blah blah " + anotherSchema.toString()
+ "bloo blah blah" + HCatSchemaUtil.getSchemaFromTypeInfo(blahTypeInfo));
{code}
It's entirely likely that the debug level for the caller is not set, and thus,
log4j would not log that line. So, doing something like this instead :
{code:java}
if (LOG.isDebugEnabled()){
LOG.debug(
mySchema.toString()
+ " : blah blah blah " + anotherSchema.toString()
+ "bloo blah blah" +
HCatSchemaUtil.getSchemaFromTypeInfo(blahTypeInfo));
}
{code}
Then the execution is identical, except for the evaluation of the call
parameters as long as the parameters don't have any side-effects, and is much
faster in cases where calculating the item to be logged would be expensive. So,
the goal was to code-scrub to find such instances, and replace where possible.
> Logging from HCat
> -----------------
>
> Key: HCATALOG-68
> URL: https://issues.apache.org/jira/browse/HCATALOG-68
> Project: HCatalog
> Issue Type: Improvement
> Reporter: Sushanth Sowmyan
>
> We need to do the following things:
> + Use log4j across the board
> + Introduce a class with methods to help logging, refactoring away the
> bunch of these functions in HCatUtil right now
> + Instrument debug logging with isLogEnabled checks on the log level
> + remove all instances of commented code whose purpose was for debug logs
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira