You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Joe Stein (Created) (JIRA)" <ji...@apache.org> on 2011/11/06 18:53:51 UTC
[jira] [Created] (KAFKA-193) use by name paramater helper for
logging and trait to include lazy logging and refactor code to use the new
LogHelper
use by name paramater helper for logging and trait to include lazy logging and refactor code to use the new LogHelper
---------------------------------------------------------------------------------------------------------------------
Key: KAFKA-193
URL: https://issues.apache.org/jira/browse/KAFKA-193
Project: Kafka
Issue Type: Improvement
Reporter: Joe Stein
1) New tait to include logging and helper methods so if (log.isDebugEnabled()) is not required because it is in the helper and log paramaters are passed by name so not executed to tidy up the code
2) refactor all occurrence of logging to use the log helper
3/4 (possibly to be handled in to tickets) the "lint" affect from this for changes patched but not on trunk and new patches moving forward until this is baked in
--
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
[jira] [Commented] (KAFKA-193) use by name parameter helper for
logging and trait to include lazy logging and refactor code to use the new
LogHelper
Posted by "Joe Stein (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/KAFKA-193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13148985#comment-13148985 ]
Joe Stein commented on KAFKA-193:
---------------------------------
Well, error and fatal have overloaded for throwable since existing code used this... error(e) can still be done the old way (I was coding to keep consistent but we can improve some too)
Yes, toString() on the throwable object just is a short description, the message, yup. Bad (my opinion)
debug(m: => String) did not get debug(m: => Throwable) because no one was doing that yet in the code.
as far as good, my preference/opinion is if you are going to log something to make it useful and informational. stack traces are best
if we accept throwable for every level we could always take that object and do getStackTrace().toString() http://download.oracle.com/javase/6/docs/api/java/lang/Throwable.html#getStackTrace() and then log that result underneath them
e.g.
def debug(e: => Throwable): Any = {
logger.debug(e.getStackTrace().toString())
}
so folks can do error(e) and we can still get what we want/need in the logs
so how about I change all of the levels in LogHelper to accept throwable as a paramater and to use this stacktrace extraction and to string that for logging?
anything else?
> use by name parameter helper for logging and trait to include lazy logging and refactor code to use the new LogHelper
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-193
> URL: https://issues.apache.org/jira/browse/KAFKA-193
> Project: Kafka
> Issue Type: Improvement
> Affects Versions: 0.7
> Reporter: Joe Stein
> Fix For: 0.8
>
> Attachments: kafka-193.patch
>
>
> 1) New tait to include logging and helper methods so if (log.isDebugEnabled()) is not required because it is in the helper and log paramaters are passed by name so not executed to tidy up the code
> 2) refactor all occurrence of logging to use the log helper
> 3/4 (possibly to be handled in to tickets) the "lint" affect from this for changes patched but not on trunk and new patches moving forward until this is baked in
--
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
[jira] [Updated] (KAFKA-193) use by name parameter helper for
logging and trait to include lazy logging and refactor code to use the new
LogHelper
Posted by "Joe Stein (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/KAFKA-193?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Joe Stein updated KAFKA-193:
----------------------------
Summary: use by name parameter helper for logging and trait to include lazy logging and refactor code to use the new LogHelper (was: use by name paramater helper for logging and trait to include lazy logging and refactor code to use the new LogHelper)
> use by name parameter helper for logging and trait to include lazy logging and refactor code to use the new LogHelper
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-193
> URL: https://issues.apache.org/jira/browse/KAFKA-193
> Project: Kafka
> Issue Type: Improvement
> Reporter: Joe Stein
>
> 1) New tait to include logging and helper methods so if (log.isDebugEnabled()) is not required because it is in the helper and log paramaters are passed by name so not executed to tidy up the code
> 2) refactor all occurrence of logging to use the log helper
> 3/4 (possibly to be handled in to tickets) the "lint" affect from this for changes patched but not on trunk and new patches moving forward until this is baked in
--
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
[jira] [Commented] (KAFKA-193) use by name parameter helper for
logging and trait to include lazy logging and refactor code to use the new
LogHelper
Posted by "Jay Kreps (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/KAFKA-193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13148974#comment-13148974 ]
Jay Kreps commented on KAFKA-193:
---------------------------------
This looks good to me.
One thing I notice is that the type of the argument is, for example,
debug(m: =>String)
but the type in log4j is
void debug(Object m)
Is this intentional? There are two impacts from this:
Good: people will no longer do
error(e)
The problem with this is that I think it uses e.toString which doesn't print the stack trace but just prints the message.
Bad(?): I can no longer print a non-string without calling toString, e.g.
debug(kafkaRequestObj)
> use by name parameter helper for logging and trait to include lazy logging and refactor code to use the new LogHelper
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-193
> URL: https://issues.apache.org/jira/browse/KAFKA-193
> Project: Kafka
> Issue Type: Improvement
> Affects Versions: 0.7
> Reporter: Joe Stein
> Fix For: 0.8
>
> Attachments: kafka-193.patch
>
>
> 1) New tait to include logging and helper methods so if (log.isDebugEnabled()) is not required because it is in the helper and log paramaters are passed by name so not executed to tidy up the code
> 2) refactor all occurrence of logging to use the log helper
> 3/4 (possibly to be handled in to tickets) the "lint" affect from this for changes patched but not on trunk and new patches moving forward until this is baked in
--
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
[jira] [Commented] (KAFKA-193) use by name parameter helper for
logging and trait to include lazy logging and refactor code to use the new
LogHelper
Posted by "Jun Rao (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/KAFKA-193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13188862#comment-13188862 ]
Jun Rao commented on KAFKA-193:
-------------------------------
We are seeing a weird issue related to this patch. The following java class won't compile.
public class MyTest extends kafka.consumer.storage.sql.OracleOffsetStorage
{
public MyTest() {
super(null);
}
}
The compilation error is:
fatal(scala.Function0) in kafka.consumer.storage.sql.OracleOffsetStorage cannot implement fatal(scala.Function0<java.lang.String>) in kafka.utils.Logging; attempting to use incompatible return type
found : java.lang.Object
required: void
A similar scala class like the following compiles fine.
class MyTest() extends kafka.consumer.storage.sql.OracleOffsetStorage(null) {
}
Anyone knows the issue?
> use by name parameter helper for logging and trait to include lazy logging and refactor code to use the new LogHelper
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-193
> URL: https://issues.apache.org/jira/browse/KAFKA-193
> Project: Kafka
> Issue Type: Improvement
> Affects Versions: 0.7
> Reporter: Joe Stein
> Assignee: Jay Kreps
> Fix For: 0.8
>
> Attachments: kafka-193-consistent-level-throwable.fix.patch, kafka-193-consistent-level-throwable.fix.v2.patch, kafka-193-consistent-level-throwable.patch, kafka-193.patch
>
>
> 1) New tait to include logging and helper methods so if (log.isDebugEnabled()) is not required because it is in the helper and log paramaters are passed by name so not executed to tidy up the code
> 2) refactor all occurrence of logging to use the log helper
> 3/4 (possibly to be handled in to tickets) the "lint" affect from this for changes patched but not on trunk and new patches moving forward until this is baked in
--
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
[jira] [Issue Comment Edited] (KAFKA-193) use by name parameter
helper for logging and trait to include lazy logging and refactor code to
use the new LogHelper
Posted by "Joe Stein (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/KAFKA-193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13149744#comment-13149744 ]
Joe Stein edited comment on KAFKA-193 at 11/16/11 9:32 PM:
-----------------------------------------------------------
I tested your approach and that works great just like we want.
Attached patch "kafka-193-consistent-level-throwable.fix.patch" to coincide with that.
was (Author: joestein):
I tested your approach and that works great just like we want.
Attached patch to coincide with that.
> use by name parameter helper for logging and trait to include lazy logging and refactor code to use the new LogHelper
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-193
> URL: https://issues.apache.org/jira/browse/KAFKA-193
> Project: Kafka
> Issue Type: Improvement
> Affects Versions: 0.7
> Reporter: Joe Stein
> Fix For: 0.8
>
> Attachments: kafka-193-consistent-level-throwable.fix.patch, kafka-193-consistent-level-throwable.patch, kafka-193.patch
>
>
> 1) New tait to include logging and helper methods so if (log.isDebugEnabled()) is not required because it is in the helper and log paramaters are passed by name so not executed to tidy up the code
> 2) refactor all occurrence of logging to use the log helper
> 3/4 (possibly to be handled in to tickets) the "lint" affect from this for changes patched but not on trunk and new patches moving forward until this is baked in
--
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
[jira] [Updated] (KAFKA-193) use by name parameter helper for
logging and trait to include lazy logging and refactor code to use the new
LogHelper
Posted by "Joe Stein (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/KAFKA-193?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Joe Stein updated KAFKA-193:
----------------------------
Attachment: kafka-193-consistent-level-throwable.patch
ok, I redid the LogHelper to have
1) consistent functions for all levels
2) format for the throwable object (using toString() on the StackTraceElement http://download.oracle.com/javase/6/docs/api/java/lang/StackTraceElement.html#toString())
3) formated both when a string and throwable are passed at the same time.
4) helper functions for 2 and 3
> use by name parameter helper for logging and trait to include lazy logging and refactor code to use the new LogHelper
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-193
> URL: https://issues.apache.org/jira/browse/KAFKA-193
> Project: Kafka
> Issue Type: Improvement
> Affects Versions: 0.7
> Reporter: Joe Stein
> Fix For: 0.8
>
> Attachments: kafka-193-consistent-level-throwable.patch, kafka-193.patch
>
>
> 1) New tait to include logging and helper methods so if (log.isDebugEnabled()) is not required because it is in the helper and log paramaters are passed by name so not executed to tidy up the code
> 2) refactor all occurrence of logging to use the log helper
> 3/4 (possibly to be handled in to tickets) the "lint" affect from this for changes patched but not on trunk and new patches moving forward until this is baked in
--
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
[jira] [Commented] (KAFKA-193) use by name parameter helper for
logging and trait to include lazy logging and refactor code to use the new
LogHelper
Posted by "Joe Stein (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/KAFKA-193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13188880#comment-13188880 ]
Joe Stein commented on KAFKA-193:
---------------------------------
The issue looks like it is with Scala 2.8.0
I build and use a Kafka jar against 2.9.1 and with that Kafka jar your MyTest.java compiles fine
I also just tried 2.8.2 and that also worked, can you bump your scala version build a jar and use that?
> use by name parameter helper for logging and trait to include lazy logging and refactor code to use the new LogHelper
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-193
> URL: https://issues.apache.org/jira/browse/KAFKA-193
> Project: Kafka
> Issue Type: Improvement
> Affects Versions: 0.7
> Reporter: Joe Stein
> Assignee: Jay Kreps
> Fix For: 0.8
>
> Attachments: kafka-193-consistent-level-throwable.fix.patch, kafka-193-consistent-level-throwable.fix.v2.patch, kafka-193-consistent-level-throwable.patch, kafka-193.patch
>
>
> 1) New tait to include logging and helper methods so if (log.isDebugEnabled()) is not required because it is in the helper and log paramaters are passed by name so not executed to tidy up the code
> 2) refactor all occurrence of logging to use the log helper
> 3/4 (possibly to be handled in to tickets) the "lint" affect from this for changes patched but not on trunk and new patches moving forward until this is baked in
--
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
[jira] [Updated] (KAFKA-193) use by name parameter helper for
logging and trait to include lazy logging and refactor code to use the new
LogHelper
Posted by "Joe Stein (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/KAFKA-193?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Joe Stein updated KAFKA-193:
----------------------------
Fix Version/s: 0.8
Affects Version/s: 0.7
Status: Patch Available (was: Open)
> use by name parameter helper for logging and trait to include lazy logging and refactor code to use the new LogHelper
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-193
> URL: https://issues.apache.org/jira/browse/KAFKA-193
> Project: Kafka
> Issue Type: Improvement
> Affects Versions: 0.7
> Reporter: Joe Stein
> Fix For: 0.8
>
> Attachments: kafka-193.patch
>
>
> 1) New tait to include logging and helper methods so if (log.isDebugEnabled()) is not required because it is in the helper and log paramaters are passed by name so not executed to tidy up the code
> 2) refactor all occurrence of logging to use the log helper
> 3/4 (possibly to be handled in to tickets) the "lint" affect from this for changes patched but not on trunk and new patches moving forward until this is baked in
--
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
[jira] [Commented] (KAFKA-193) use by name parameter helper for
logging and trait to include lazy logging and refactor code to use the new
LogHelper
Posted by "Jay Kreps (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/KAFKA-193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13149120#comment-13149120 ]
Jay Kreps commented on KAFKA-193:
---------------------------------
Yeah so my recommendations.
1. Let's have the same variants for each level for consistency. Sounds like that is info(m:=>String), info(m:=>String, t: Throwable) and info(t: Throwable).
2. I am cool with either String or Object as the message type (e.g. info(m:=>String) or info(m:=>Object). I don't see a great benefit of the Object type in log4j.
3. Let's definitely make the form that takes only a throwable print the stack trace. I think t.getStackTrace() won't quite do it because the return value is just an array. We can probably have that do info("", t), which I think would do what we want (?) or we have a utility function which I think formats the stack trace.
> use by name parameter helper for logging and trait to include lazy logging and refactor code to use the new LogHelper
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-193
> URL: https://issues.apache.org/jira/browse/KAFKA-193
> Project: Kafka
> Issue Type: Improvement
> Affects Versions: 0.7
> Reporter: Joe Stein
> Fix For: 0.8
>
> Attachments: kafka-193.patch
>
>
> 1) New tait to include logging and helper methods so if (log.isDebugEnabled()) is not required because it is in the helper and log paramaters are passed by name so not executed to tidy up the code
> 2) refactor all occurrence of logging to use the log helper
> 3/4 (possibly to be handled in to tickets) the "lint" affect from this for changes patched but not on trunk and new patches moving forward until this is baked in
--
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
[jira] [Updated] (KAFKA-193) use by name parameter helper for
logging and trait to include lazy logging and refactor code to use the new
LogHelper
Posted by "Jay Kreps (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/KAFKA-193?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jay Kreps updated KAFKA-193:
----------------------------
Resolution: Fixed
Assignee: Jay Kreps
Status: Resolved (was: Patch Available)
Epic patch committed.
> use by name parameter helper for logging and trait to include lazy logging and refactor code to use the new LogHelper
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-193
> URL: https://issues.apache.org/jira/browse/KAFKA-193
> Project: Kafka
> Issue Type: Improvement
> Affects Versions: 0.7
> Reporter: Joe Stein
> Assignee: Jay Kreps
> Fix For: 0.8
>
> Attachments: kafka-193-consistent-level-throwable.fix.patch, kafka-193-consistent-level-throwable.fix.v2.patch, kafka-193-consistent-level-throwable.patch, kafka-193.patch
>
>
> 1) New tait to include logging and helper methods so if (log.isDebugEnabled()) is not required because it is in the helper and log paramaters are passed by name so not executed to tidy up the code
> 2) refactor all occurrence of logging to use the log helper
> 3/4 (possibly to be handled in to tickets) the "lint" affect from this for changes patched but not on trunk and new patches moving forward until this is baked in
--
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
[jira] [Updated] (KAFKA-193) use by name parameter helper for
logging and trait to include lazy logging and refactor code to use the new
LogHelper
Posted by "Joe Stein (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/KAFKA-193?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Joe Stein updated KAFKA-193:
----------------------------
Attachment: kafka-193.patch
new trait in utils/Logging.scala
scoured trunk and re-factored to use trait
handling the incremental updates for patches that go to trunk before this patch can maybe just be more patches on this ticket. after this patch goes to trunk it would be great that any new patches start to use the trait.
> use by name parameter helper for logging and trait to include lazy logging and refactor code to use the new LogHelper
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-193
> URL: https://issues.apache.org/jira/browse/KAFKA-193
> Project: Kafka
> Issue Type: Improvement
> Reporter: Joe Stein
> Attachments: kafka-193.patch
>
>
> 1) New tait to include logging and helper methods so if (log.isDebugEnabled()) is not required because it is in the helper and log paramaters are passed by name so not executed to tidy up the code
> 2) refactor all occurrence of logging to use the log helper
> 3/4 (possibly to be handled in to tickets) the "lint" affect from this for changes patched but not on trunk and new patches moving forward until this is baked in
--
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
[jira] [Updated] (KAFKA-193) use by name parameter helper for
logging and trait to include lazy logging and refactor code to use the new
LogHelper
Posted by "Jay Kreps (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/KAFKA-193?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jay Kreps updated KAFKA-193:
----------------------------
Attachment: kafka-193-consistent-level-throwable.fix.v2.patch
Cool, here is the same patch updated against trunk to fix a few new breakages due to new checkins. I also made two minor changes:
1. Changed LogHelper trait to Logging and made the file name match the trait name. Motivation here is just to make the name trait-like...
2. Made Utils.registerMbean not throw an exception. Utils.swallow was depending on log4j and this lead to a lot of unnecessary use of log4j directly. I think it is better for jmx registration to not be a fatal exception (JMX shouldn't kill the server or client, just log an error).
If no objections to these I am going to apply the updated patch.
> use by name parameter helper for logging and trait to include lazy logging and refactor code to use the new LogHelper
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-193
> URL: https://issues.apache.org/jira/browse/KAFKA-193
> Project: Kafka
> Issue Type: Improvement
> Affects Versions: 0.7
> Reporter: Joe Stein
> Fix For: 0.8
>
> Attachments: kafka-193-consistent-level-throwable.fix.patch, kafka-193-consistent-level-throwable.fix.v2.patch, kafka-193-consistent-level-throwable.patch, kafka-193.patch
>
>
> 1) New tait to include logging and helper methods so if (log.isDebugEnabled()) is not required because it is in the helper and log paramaters are passed by name so not executed to tidy up the code
> 2) refactor all occurrence of logging to use the log helper
> 3/4 (possibly to be handled in to tickets) the "lint" affect from this for changes patched but not on trunk and new patches moving forward until this is baked in
--
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
[jira] [Commented] (KAFKA-193) use by name parameter helper for
logging and trait to include lazy logging and refactor code to use the new
LogHelper
Posted by "Jay Kreps (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/KAFKA-193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13149445#comment-13149445 ]
Jay Kreps commented on KAFKA-193:
---------------------------------
Hmm, have you tried this out? Not sure if that works. You are doing
def throwableString(e: => Throwable) = e.getStackTrace.toString
But getStackTrace gives a java array primitive, so that doesn't print a stack trace:
jkreps-mn:~ jkreps$ scala
scala> val e = new RuntimeException("Hello")
e: java.lang.RuntimeException = java.lang.RuntimeException: Hello
scala> e.getStackTrace.toString
res8: java.lang.String = [Ljava.lang.StackTraceElement;@4439bc82
What if instead we stick with log4j and do the following variants (for info/debug/trace/error/fatal):
def info(m: =>String) = if(logger.isInfoEnabled) logger.info(m)
def info(m: =>String, e: Throwable) = if(logger.isInfoEnabled) logger.info(m, e)
def info(e: Throwable) = if(logger.isInfoEnabled) logger.info("", e)
I think this does what we want with respect to exceptions.
> use by name parameter helper for logging and trait to include lazy logging and refactor code to use the new LogHelper
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-193
> URL: https://issues.apache.org/jira/browse/KAFKA-193
> Project: Kafka
> Issue Type: Improvement
> Affects Versions: 0.7
> Reporter: Joe Stein
> Fix For: 0.8
>
> Attachments: kafka-193-consistent-level-throwable.patch, kafka-193.patch
>
>
> 1) New tait to include logging and helper methods so if (log.isDebugEnabled()) is not required because it is in the helper and log paramaters are passed by name so not executed to tidy up the code
> 2) refactor all occurrence of logging to use the log helper
> 3/4 (possibly to be handled in to tickets) the "lint" affect from this for changes patched but not on trunk and new patches moving forward until this is baked in
--
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
[jira] [Updated] (KAFKA-193) use by name parameter helper for
logging and trait to include lazy logging and refactor code to use the new
LogHelper
Posted by "Joe Stein (Updated) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/KAFKA-193?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Joe Stein updated KAFKA-193:
----------------------------
Attachment: kafka-193-consistent-level-throwable.fix.patch
I tested your approach and that works great just like we want.
Attached patch to coincide with that.
> use by name parameter helper for logging and trait to include lazy logging and refactor code to use the new LogHelper
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-193
> URL: https://issues.apache.org/jira/browse/KAFKA-193
> Project: Kafka
> Issue Type: Improvement
> Affects Versions: 0.7
> Reporter: Joe Stein
> Fix For: 0.8
>
> Attachments: kafka-193-consistent-level-throwable.fix.patch, kafka-193-consistent-level-throwable.patch, kafka-193.patch
>
>
> 1) New tait to include logging and helper methods so if (log.isDebugEnabled()) is not required because it is in the helper and log paramaters are passed by name so not executed to tidy up the code
> 2) refactor all occurrence of logging to use the log helper
> 3/4 (possibly to be handled in to tickets) the "lint" affect from this for changes patched but not on trunk and new patches moving forward until this is baked in
--
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
[jira] [Commented] (KAFKA-193) use by name parameter helper for
logging and trait to include lazy logging and refactor code to use the new
LogHelper
Posted by "Jun Rao (Commented) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/KAFKA-193?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13155691#comment-13155691 ]
Jun Rao commented on KAFKA-193:
-------------------------------
+1 on the latest patch.
> use by name parameter helper for logging and trait to include lazy logging and refactor code to use the new LogHelper
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-193
> URL: https://issues.apache.org/jira/browse/KAFKA-193
> Project: Kafka
> Issue Type: Improvement
> Affects Versions: 0.7
> Reporter: Joe Stein
> Fix For: 0.8
>
> Attachments: kafka-193-consistent-level-throwable.fix.patch, kafka-193-consistent-level-throwable.fix.v2.patch, kafka-193-consistent-level-throwable.patch, kafka-193.patch
>
>
> 1) New tait to include logging and helper methods so if (log.isDebugEnabled()) is not required because it is in the helper and log paramaters are passed by name so not executed to tidy up the code
> 2) refactor all occurrence of logging to use the log helper
> 3/4 (possibly to be handled in to tickets) the "lint" affect from this for changes patched but not on trunk and new patches moving forward until this is baked in
--
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