Note that there are some explanatory texts on larger screens.

plurals
  1. USbsdfish
    primarykey
    data
    text
    plurals
    1. This table or related slice is empty.
    1. CO@peter: it is the bottleneck. I am writing a latency-sensitive app and the logging stuff is responsible for about 90% of the garbage generated ... I wanted to know if there was a way of doing what I was asking for in java. It's pretty easy in C++ w/ preprocessor and/or templates. In Lisp, I would make log a macro that would implicitly generate the if(correctLogLevelEnabled).
      singulars
    2. COOf course it's littering! It's a major abstraction violation and makes the code harder to read, as well as making mistakes more likely. in reality, it would have to be something like if(log.isLogLevelEnabled(LogLevel.A_LOG_LEVEL) log.log(LogLevel.A_LOG_LEVEL, formatString, formatArgs). Or, the log statement can not take in a log level, making it vulnerable to the bug of not checking whether the statement should get printed.
      singulars
    3. COThanks for your answer. In the real program, the code I'm writing is a wrapper around log4j that adds some features. However, my understanding is that log4j suffers from the same problem. In particular, the section that you point to, bullet point 1. specifies exactly the cost I'm trying to minimize. It suggests an unappealing alternative -- littering my non-logging code with if(isLogging) { doLog(); } constructs. I am hoping to find a cleaner way. In C++, I'd use templates to auto-generate a whole bunch of logger methods that would avoid boxing ...
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload