/** * Configures the default {@linkplain ConsoleHandler console handler} in order to log records * on a single line instead of two lines. More specifically, for each {@link ConsoleHandler} * using a {@link SimpleFormatter}, this method replaces the simple formatter by an instance * of {@link MonolineFormatter}. If no {@link ConsoleHandler} are found, then a new one is * created. * <p> * Note that {@link MonolineFormatter} writes to the {@linkplain System#out standard * output stream} instead of the {@linkplain System#err standard error stream}. * * @throws IllegalStateException is {@link #redirectToCommonsLogging} has been invoked. */ public void forceMonolineConsoleOutput() throws IllegalStateException { forceMonolineConsoleOutput(null); }
/** * Invoked when an error occurs during the initialization. */ private static void unexpectedException(final Exception e) { Logging.unexpectedException("org.geotools.util", MonolineFormatter.class, "init", e); }
try { if (CommonHandler.install(root)) { assert isCommonsLoggingAvailable(); redirected = true; return true;
/** * Invoked when an unexpected error occurs. This method logs a message at the * {@link Level#WARNING WARNING} level to the logger for the specified package * name. The originating class name and method name can optionnaly be specified. * If any of them is {@code null}, then it will be inferred from the error stack * trace as in {@link #unexpectedException(Logger, Throwable)}. * * @param paquet The package where the error occurred, or {@code null}. This * information is used for fetching an appropriate {@link Logger} * for logging the error. * @param classe The class where the error occurred, or {@code null}. * @param method The method where the error occurred, or {@code null}. * @param error The error. */ public static void unexpectedException(final String paquet, final Class classe, final String method, final Throwable error) { // TODO: use getSimpleName() or getCanonicalName() when we will be allowed to target J2SE 1.5. unexpectedException(paquet, (classe != null) ? classe.getName() : (String) null, method, error); }
unexpectedException(logger.getName(), classe, method, error);
/** * Invoked when an unexpected error occurs. This method logs a message at the * {@link Level#WARNING WARNING} level to the specified logger. The originating * class name and method name are inferred from the error stack trace, using the * first {@linkplain StackTraceElement stack trace element} for which the class * name is inside a package or sub-package of the logger name. For example if * the logger name is {@code "org.geotools.image"}, then this method will uses * the first stack trace element where the fully qualified class name starts with * {@code "org.geotools.image"} or {@code "org.geotools.image.io"}, but not * {@code "org.geotools.imageio"}. * * @param logger Where to log the error. * @param error The error that occured. * @return {@code true} if the error has been logged, or {@code false} if the logger * doesn't log anything at the {@link Level#WARNING WARNING} level. */ public static boolean unexpectedException(final Logger logger, final Throwable error) { if (logger.isLoggable(Level.WARNING)) { unexpectedException(logger.getName(), (String) null, null, error); return true; } return false; }