/* * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package sun.util.logging; import java.lang.System.Logger; import java.util.ResourceBundle; import java.util.function.Supplier; import sun.util.logger.LoggerWrapper; import sun.util.logging.PlatformLogger.Level; /** * Platform logger provides an API for the JRE components to log * messages. * * The PlatformLoggerBridge interface is implemented by the System.Logger * objects returned by our default JUL provider - so that JRE classes using * PlatformLogger see no difference when JUL is the actual backend. * * The recommendation for JRE classes going forward is to use * java.lang.System.getLogger(String name), which will * use Lazy Loggers when possible and necessary. * * PlatformLogger is now only a thin adaptation layer over the same * loggers than returned by java.lang.System.getLogger(String name). * * @since 1.9 */ public interface PlatformLoggerBridge { /** * Gets the name for this platform logger. * @return the name of the platform logger. */ public String getName(); /** * Returns true if a message of the given level would actually * be logged by this logger. * @param level the level * @return whether a message of that level would be logged */ public boolean isLoggable(Level level); public boolean isEnabled(); public void log(Level level, String msg); public void log(Level level, String msg, Throwable thrown); public void log(Level level, String msg, Object... params); public void log(Level level, Supplier msgSupplier); public void log(Level level, Throwable thrown, Supplier msgSupplier); public void logp(Level level, String sourceClass, String sourceMethod, String msg); public void logp(Level level, String sourceClass, String sourceMethod, Supplier msgSupplier); public void logp(Level level, String sourceClass, String sourceMethod, String msg, Object... params); public void logp(Level level, String sourceClass, String sourceMethod, String msg, Throwable thrown); public void logp(Level level, String sourceClass, String sourceMethod, Throwable thrown, Supplier msgSupplier); public void logrb(Level level, String sourceClass, String sourceMethod, ResourceBundle bundle, String msg, Object... params); public void logrb(Level level, String sourceClass, String sourceMethod, ResourceBundle bundle, String msg, Throwable thrown); public void logrb(Level level, ResourceBundle bundle, String msg, Object... params); public void logrb(Level level, ResourceBundle bundle, String msg, Throwable thrown); public static PlatformLoggerBridge convert(Logger logger) { if (logger instanceof PlatformLoggerBridge) { return (PlatformLoggerBridge) logger; } else { return new LoggerWrapper<>(logger); } } }