< prev index next >

modules/javafx.base/src/main/java/com/sun/javafx/logging/PlatformLogger.java

Print this page




   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.javafx.logging;
  27 
  28 import java.lang.ref.WeakReference;
  29 import java.util.Arrays;
  30 import java.util.HashMap;
  31 import java.util.Map;
  32 import java.util.ResourceBundle;
  33 
  34 /**
  35  * Platform logger provides an API for the JavaFX components to log
  36  * messages. It is an internal logger intended to be used by JavaFX modules.
  37  *
  38  * The PlatformLogger uses an underlying System.Logger
  39  * obtained by calling {@link java.lang.System.Logger#getLogger(String)}
  40  *
  41  * PlatformLogger implements System.Logger as to facilitiate logging of
  42  * calling class and method.
  43  * Note : JDK internal loggers know to skip any calls from System.Logger
  44  * classes when looking for the calling class / method.
  45  */
  46 public class PlatformLogger implements System.Logger {
  47 
  48     /**
  49      * PlatformLogger logging levels.


  88     /**
  89      * Returns a PlatformLogger of a given name.
  90      * @param name the name of the logger
  91      * @return a PlatformLogger
  92      */
  93     public static synchronized PlatformLogger getLogger(String name) {
  94         PlatformLogger log = null;
  95         WeakReference<PlatformLogger> ref = loggers.get(name);
  96         if (ref != null) {
  97             log = ref.get();
  98         }
  99         if (log == null) {
 100             log = new PlatformLogger(System.getLogger(name));
 101             loggers.put(name, new WeakReference<>(log));
 102         }
 103         return log;
 104     }
 105 
 106 
 107     private final System.Logger loggerProxy;
 108     private PlatformLogger(System.Logger loggerProxy) {
 109         this.loggerProxy = loggerProxy;
 110     }
 111 
 112     // ------------------------------------------------------------------------
 113     //          From System.Logger interface
 114     // ------------------------------------------------------------------------
 115 
 116     /**
 117      * Gets the name for this platform logger.
 118      * @return the name of the platform logger.
 119      */
 120     @Override
 121     public String getName() {
 122        throw new UnsupportedOperationException("not implemented");
 123     }
 124 
 125     @Override
 126     public boolean isLoggable(System.Logger.Level level) {
 127         throw new UnsupportedOperationException("not implemented");
 128     }




   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.javafx.logging;
  27 
  28 import java.lang.ref.WeakReference;

  29 import java.util.HashMap;
  30 import java.util.Map;
  31 import java.util.ResourceBundle;
  32 
  33 /**
  34  * Platform logger provides an API for the JavaFX components to log
  35  * messages. It is an internal logger intended to be used by JavaFX modules.
  36  *
  37  * The PlatformLogger uses an underlying System.Logger
  38  * obtained by calling {@link java.lang.System.Logger#getLogger(String)}
  39  *
  40  * PlatformLogger implements System.Logger as to facilitiate logging of
  41  * calling class and method.
  42  * Note : JDK internal loggers know to skip any calls from System.Logger
  43  * classes when looking for the calling class / method.
  44  */
  45 public class PlatformLogger implements System.Logger {
  46 
  47     /**
  48      * PlatformLogger logging levels.


  87     /**
  88      * Returns a PlatformLogger of a given name.
  89      * @param name the name of the logger
  90      * @return a PlatformLogger
  91      */
  92     public static synchronized PlatformLogger getLogger(String name) {
  93         PlatformLogger log = null;
  94         WeakReference<PlatformLogger> ref = loggers.get(name);
  95         if (ref != null) {
  96             log = ref.get();
  97         }
  98         if (log == null) {
  99             log = new PlatformLogger(System.getLogger(name));
 100             loggers.put(name, new WeakReference<>(log));
 101         }
 102         return log;
 103     }
 104 
 105 
 106     private final System.Logger loggerProxy;
 107     protected PlatformLogger(System.Logger loggerProxy) {
 108         this.loggerProxy = loggerProxy;
 109     }
 110 
 111     // ------------------------------------------------------------------------
 112     //          From System.Logger interface
 113     // ------------------------------------------------------------------------
 114 
 115     /**
 116      * Gets the name for this platform logger.
 117      * @return the name of the platform logger.
 118      */
 119     @Override
 120     public String getName() {
 121        throw new UnsupportedOperationException("not implemented");
 122     }
 123 
 124     @Override
 125     public boolean isLoggable(System.Logger.Level level) {
 126         throw new UnsupportedOperationException("not implemented");
 127     }


< prev index next >