-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
8
-
None
-
generic
-
generic
The JUL Logger API has methods such as:
public void log(Level level, String msg, Object params[])
This makes the code somewhat ugly, whereas converting that last argument to a varargs would make it lovely.
// A bit clunky
LOG.log(Level.SEVERE, "Failed to deploy bundle {0}\n{1}", new Object[] { bundleName, e });
// A bit nicer
LOG.log(Level.SEVERE, "Failed to deploy bundle {0}\n{1}", bundleName, e);
Another little pet peeve, I prefer not to use the log methods, but instead the "warning", "severe" etc methods because it makes the code very readable and also means that I don't have to either statically import "Level" or prefix everything with Level. However these methods are missing variants for handling formatted text, which makes them less than useful.
// Well, with varargs a bit nicer
LOG.log(Level.SEVERE, "Failed to deploy bundle {0}\n{1}", bundleName, e);
// Nirvana
LOG.severe("Failed to deploy bundle {0}\n{1}", bundleName, e);
And just to drive home the point:
// What I have to do today:
LOG.log(Level.SEVERE, "Failed to deploy bundle {0}\n{1}", new Object[] { bundleName, e });
// What I'd like to see
LOG.severe("Failed to deploy bundle {0}\n{1}", bundleName, e);
public void log(Level level, String msg, Object params[])
This makes the code somewhat ugly, whereas converting that last argument to a varargs would make it lovely.
// A bit clunky
LOG.log(Level.SEVERE, "Failed to deploy bundle {0}\n{1}", new Object[] { bundleName, e });
// A bit nicer
LOG.log(Level.SEVERE, "Failed to deploy bundle {0}\n{1}", bundleName, e);
Another little pet peeve, I prefer not to use the log methods, but instead the "warning", "severe" etc methods because it makes the code very readable and also means that I don't have to either statically import "Level" or prefix everything with Level. However these methods are missing variants for handling formatted text, which makes them less than useful.
// Well, with varargs a bit nicer
LOG.log(Level.SEVERE, "Failed to deploy bundle {0}\n{1}", bundleName, e);
// Nirvana
LOG.severe("Failed to deploy bundle {0}\n{1}", bundleName, e);
And just to drive home the point:
// What I have to do today:
LOG.log(Level.SEVERE, "Failed to deploy bundle {0}\n{1}", new Object[] { bundleName, e });
// What I'd like to see
LOG.severe("Failed to deploy bundle {0}\n{1}", bundleName, e);
- relates to
-
JDK-5001993 Use varargs in java.util.logging.Logger
-
- Open
-