< prev index next >

jdk/src/java.logging/share/classes/java/util/logging/Logger.java

Print this page

        

*** 445,456 **** } } private static Logger demandLogger(String name, String resourceBundleName, Class<?> caller) { LogManager manager = LogManager.getLogManager(); ! SecurityManager sm = System.getSecurityManager(); ! if (sm != null && !SystemLoggerHelper.disableCallerCheck) { if (caller.getClassLoader() == null) { return manager.demandSystemLogger(name, resourceBundleName, caller); } } return manager.demandLogger(name, resourceBundleName, caller); --- 445,455 ---- } } private static Logger demandLogger(String name, String resourceBundleName, Class<?> caller) { LogManager manager = LogManager.getLogManager(); ! if (!SystemLoggerHelper.disableCallerCheck) { if (caller.getClassLoader() == null) { return manager.demandSystemLogger(name, resourceBundleName, caller); } } return manager.demandLogger(name, resourceBundleName, caller);
*** 1252,1269 **** /** * Log a message, specifying source class, method, and resource bundle, * with an optional list of message parameters. * <p> * If the logger is currently enabled for the given message ! * level then a corresponding LogRecord is created and forwarded ! * to all the registered output Handler objects. * <p> * The {@code msg} string is localized using the given resource bundle. * If the resource bundle is {@code null}, then the {@code msg} string is not * localized. * ! * @param level One of the message level identifiers, e.g., SEVERE * @param sourceClass Name of the class that issued the logging request * @param sourceMethod Name of the method that issued the logging request * @param bundle Resource bundle to localize {@code msg}, * can be {@code null}. * @param msg The string message (or a key in the message catalog) --- 1251,1268 ---- /** * Log a message, specifying source class, method, and resource bundle, * with an optional list of message parameters. * <p> * If the logger is currently enabled for the given message ! * {@code level} then a corresponding {@code LogRecord} is created and ! * forwarded to all the registered output {@code Handler} objects. * <p> * The {@code msg} string is localized using the given resource bundle. * If the resource bundle is {@code null}, then the {@code msg} string is not * localized. * ! * @param level One of the message level identifiers, e.g., {@code SEVERE} * @param sourceClass Name of the class that issued the logging request * @param sourceMethod Name of the method that issued the logging request * @param bundle Resource bundle to localize {@code msg}, * can be {@code null}. * @param msg The string message (or a key in the message catalog)
*** 1283,1292 **** --- 1282,1321 ---- } doLog(lr, bundle); } /** + * Log a message, specifying source class, method, and resource bundle, + * with an optional list of message parameters. + * <p> + * If the logger is currently enabled for the given message + * {@code level} then a corresponding {@code LogRecord} is created + * and forwarded to all the registered output {@code Handler} objects. + * <p> + * The {@code msg} string is localized using the given resource bundle. + * If the resource bundle is {@code null}, then the {@code msg} string is not + * localized. + * <p> + * @param level One of the message level identifiers, e.g., {@code SEVERE} + * @param bundle Resource bundle to localize {@code msg}; + * can be {@code null}. + * @param msg The string message (or a key in the message catalog) + * @param params Parameters to the message (optional, may be none). + * @since 1.9 + */ + public void logrb(Level level, ResourceBundle bundle, String msg, Object... params) { + if (!isLoggable(level)) { + return; + } + LogRecord lr = new LogRecord(level, msg); + if (params != null && params.length != 0) { + lr.setParameters(params); + } + doLog(lr, bundle); + } + + /** * Log a message, specifying source class, method, and resource bundle name, * with associated Throwable information. * <p> * If the logger is currently enabled for the given message * level then the given arguments are stored in a LogRecord
*** 1328,1350 **** /** * Log a message, specifying source class, method, and resource bundle, * with associated Throwable information. * <p> * If the logger is currently enabled for the given message ! * level then the given arguments are stored in a LogRecord * which is forwarded to all registered output handlers. * <p> * The {@code msg} string is localized using the given resource bundle. * If the resource bundle is {@code null}, then the {@code msg} string is not * localized. * <p> ! * Note that the thrown argument is stored in the LogRecord thrown ! * property, rather than the LogRecord parameters property. Thus it is ! * processed specially by output Formatters and is not treated ! * as a formatting parameter to the LogRecord message property. * ! * @param level One of the message level identifiers, e.g., SEVERE * @param sourceClass Name of the class that issued the logging request * @param sourceMethod Name of the method that issued the logging request * @param bundle Resource bundle to localize {@code msg}, * can be {@code null} * @param msg The string message (or a key in the message catalog) --- 1357,1380 ---- /** * Log a message, specifying source class, method, and resource bundle, * with associated Throwable information. * <p> * If the logger is currently enabled for the given message ! * {@code level} then the given arguments are stored in a {@code LogRecord} * which is forwarded to all registered output handlers. * <p> * The {@code msg} string is localized using the given resource bundle. * If the resource bundle is {@code null}, then the {@code msg} string is not * localized. * <p> ! * Note that the {@code thrown} argument is stored in the {@code LogRecord} ! * {@code thrown} property, rather than the {@code LogRecord} ! * {@code parameters} property. Thus it is ! * processed specially by output {@code Formatter} objects and is not treated ! * as a formatting parameter to the {@code LogRecord} {@code message} property. * ! * @param level One of the message level identifiers, e.g., {@code SEVERE} * @param sourceClass Name of the class that issued the logging request * @param sourceMethod Name of the method that issued the logging request * @param bundle Resource bundle to localize {@code msg}, * can be {@code null} * @param msg The string message (or a key in the message catalog)
*** 1361,1370 **** --- 1391,1436 ---- lr.setSourceMethodName(sourceMethod); lr.setThrown(thrown); doLog(lr, bundle); } + /** + * Log a message, specifying source class, method, and resource bundle, + * with associated Throwable information. + * <p> + * If the logger is currently enabled for the given message + * {@code level} then the given arguments are stored in a {@code LogRecord} + * which is forwarded to all registered output handlers. + * <p> + * The {@code msg} string is localized using the given resource bundle. + * If the resource bundle is {@code null}, then the {@code msg} string is not + * localized. + * <p> + * Note that the {@code thrown} argument is stored in the {@code LogRecord} + * {@code thrown} property, rather than the {@code LogRecord} + * {@code parameters} property. Thus it is + * processed specially by output {@code Formatter} objects and is not treated + * as a formatting parameter to the {@code LogRecord} {@code message} + * property. + * <p> + * @param level One of the message level identifiers, e.g., {@code SEVERE} + * @param bundle Resource bundle to localize {@code msg}; + * can be {@code null}. + * @param msg The string message (or a key in the message catalog) + * @param thrown Throwable associated with the log message. + * @since 1.9 + */ + public void logrb(Level level, ResourceBundle bundle, String msg, + Throwable thrown) { + if (!isLoggable(level)) { + return; + } + LogRecord lr = new LogRecord(level, msg); + lr.setThrown(thrown); + doLog(lr, bundle); + } + //====================================================================== // Start of convenience methods for logging method entries and returns. //====================================================================== /**
< prev index next >