Add condition to log only if fine level is loggable
Even if FINE level is not loggable String.format() works every time and tries to format string with all the events. Sometimes it causes OutOfMemory exceptions.
This commit is contained in:
@@ -77,7 +77,9 @@ public class Parser {
|
||||
public Encoder() {}
|
||||
|
||||
public void encode(Packet obj, Callback callback) {
|
||||
logger.fine(String.format("encoding packet %s", obj));
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.fine(String.format("encoding packet %s", obj));
|
||||
}
|
||||
|
||||
if (BINARY_EVENT == obj.type || BINARY_ACK == obj.type) {
|
||||
encodeAsBinary(obj, callback);
|
||||
@@ -116,7 +118,9 @@ public class Parser {
|
||||
str.append(obj.data);
|
||||
}
|
||||
|
||||
logger.fine(String.format("encoded %s as %s", obj, str));
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.fine(String.format("encoded %s as %s", obj, str));
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
@@ -233,7 +237,9 @@ public class Parser {
|
||||
}
|
||||
}
|
||||
|
||||
logger.fine(String.format("decoded %s as %s", str, p));
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.fine(String.format("decoded %s as %s", str, p));
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user