java.util.logging.Logger#getName ( )源码实例Demo

下面列出了java.util.logging.Logger#getName ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: PGM   文件: ClassLogger.java
private static String getName(
    @Nullable Logger parent, Class<?> klass, @Nullable String instanceKey) {
  Class<?> namedAncestor = getNamedAncestor(klass);
  String name;
  if (parent == null) {
    name = namedAncestor.getCanonicalName();
  } else {
    name = parent.getName() + "." + namedAncestor.getSimpleName();
  }
  if (klass.isAnonymousClass()) {
    String[] names = klass.getName().split("\\.");
    name += "." + names[names.length - 1];
  }
  if (instanceKey != null) {
    name += "." + instanceKey;
  }
  return name;
}
 
@Override
public void onCreate() {
    super.onCreate();

    Logger logger = Logger.getLogger("heartrate.dplugin");
    if (BuildConfig.DEBUG) {
        AndroidHandler handler = new AndroidHandler(logger.getName());
        handler.setFormatter(new SimpleFormatter());
        handler.setLevel(Level.ALL);
        logger.addHandler(handler);
        logger.setLevel(Level.ALL);
    } else {
        logger.setLevel(Level.OFF);
    }

    mLogger.fine("HeartRateDeviceService start.");

    if (!BleUtils.isBLESupported(this)) {
        mLogger.warning("BLE is not support.");
        return;
    }

    mHeartRateManager = new HeartRateManager(getApplicationContext());
    mHeartRateManager.addOnHeartRateDiscoveryListener(mOnDiscoveryListener);

    addProfile(new HeartRateServiceDiscoveryProfile(getServiceProvider()));
    mHeartRateProfile = new HeartRateHealthProfile(mHeartRateManager);

    List<HeartRateDevice> devices = mHeartRateManager.getRegisterDevices();
    for (HeartRateDevice device : devices) {
        retrieveService(device);
    }

    getServiceProvider().addServiceListener(this);

    registerBluetoothFilter();
}
 
源代码3 项目: dragonwell8_jdk   文件: TestSetResourceBundle.java
static void debugLogger(Logger logger, Logger expectedParent, TestHandler handler) {
    final String logName = logger.getName();
    final String prefix = "    " + logName;
    System.err.println("Logger " + logName
            + " logged with bundle name " + handler.lastBundleName
            + " (" + handler.lastBundle + ")");
    System.err.println(prefix + ".getResourceBundleName() is "
            + logger.getResourceBundleName());
    System.err.println(prefix + ".getResourceBundle() is "
            + logger.getResourceBundle());
    final Logger parent = logger.getParent();
    final String pname = parent == null ? null : parent.getName();
    final String pclass = parent == null ? ""
            : ("(" + parent.getClass().getName() + ")");
    final String presn = parent == null ? null
            : parent.getResourceBundleName();
    final ResourceBundle pres = parent == null ? null
            : parent.getResourceBundle();
    System.err.println(prefix + ".getParent() is "
            + pname + (pname == null ? ""
                    : (" " + pclass + ": " + parent)));
    System.err.println("    expected parent is :" + expectedParent);
    System.err.println(prefix + ".parent.getResourceBundleName() is "
            + presn);
    System.err.println(prefix + ".parent.getResourceBundle() is "
            + pres);
    System.err.println("    expected parent getResourceBundleName() is "
            + expectedParent.getResourceBundleName());
    System.err.println("    expected parent.getResourceBundle() is "
            + expectedParent.getResourceBundle());
}
 
源代码4 项目: openjdk-jdk9   文件: TestSetResourceBundle.java
static void debugLogger(Logger logger, Logger expectedParent, TestHandler handler) {
    final String logName = logger.getName();
    final String prefix = "    " + logName;
    System.err.println("Logger " + logName
            + " logged with bundle name " + handler.lastBundleName
            + " (" + handler.lastBundle + ")");
    System.err.println(prefix + ".getResourceBundleName() is "
            + logger.getResourceBundleName());
    System.err.println(prefix + ".getResourceBundle() is "
            + logger.getResourceBundle());
    final Logger parent = logger.getParent();
    final String pname = parent == null ? null : parent.getName();
    final String pclass = parent == null ? ""
            : ("(" + parent.getClass().getName() + ")");
    final String presn = parent == null ? null
            : parent.getResourceBundleName();
    final ResourceBundle pres = parent == null ? null
            : parent.getResourceBundle();
    System.err.println(prefix + ".getParent() is "
            + pname + (pname == null ? ""
                    : (" " + pclass + ": " + parent)));
    System.err.println("    expected parent is :" + expectedParent);
    System.err.println(prefix + ".parent.getResourceBundleName() is "
            + presn);
    System.err.println(prefix + ".parent.getResourceBundle() is "
            + pres);
    System.err.println("    expected parent getResourceBundleName() is "
            + expectedParent.getResourceBundleName());
    System.err.println("    expected parent.getResourceBundle() is "
            + expectedParent.getResourceBundle());
}
 
源代码5 项目: jdk8u60   文件: TestSetResourceBundle.java
static void debugLogger(Logger logger, Logger expectedParent, TestHandler handler) {
    final String logName = logger.getName();
    final String prefix = "    " + logName;
    System.err.println("Logger " + logName
            + " logged with bundle name " + handler.lastBundleName
            + " (" + handler.lastBundle + ")");
    System.err.println(prefix + ".getResourceBundleName() is "
            + logger.getResourceBundleName());
    System.err.println(prefix + ".getResourceBundle() is "
            + logger.getResourceBundle());
    final Logger parent = logger.getParent();
    final String pname = parent == null ? null : parent.getName();
    final String pclass = parent == null ? ""
            : ("(" + parent.getClass().getName() + ")");
    final String presn = parent == null ? null
            : parent.getResourceBundleName();
    final ResourceBundle pres = parent == null ? null
            : parent.getResourceBundle();
    System.err.println(prefix + ".getParent() is "
            + pname + (pname == null ? ""
                    : (" " + pclass + ": " + parent)));
    System.err.println("    expected parent is :" + expectedParent);
    System.err.println(prefix + ".parent.getResourceBundleName() is "
            + presn);
    System.err.println(prefix + ".parent.getResourceBundle() is "
            + pres);
    System.err.println("    expected parent getResourceBundleName() is "
            + expectedParent.getResourceBundleName());
    System.err.println("    expected parent.getResourceBundle() is "
            + expectedParent.getResourceBundle());
}
 
private static void testLoggableLevels() {

        Logger foobar = Logger.getLogger("foo.bar");
        if (!foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }

        Logger global = Logger.getGlobal();
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }

        Logger root = Logger.getLogger("");
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }

        root.setLevel(Level.FINER);

        if (foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }
        if (global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }

        if (!foobar.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }

        if (!global.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }

    }
 
源代码7 项目: dragonwell8_jdk   文件: TestLoggerBundleSync.java
@Override
public void run() {
    try {
        handler.setLevel(Level.FINEST);
        while (goOn) {
            Logger l;
            Logger foo = Logger.getLogger("foo");
            Logger bar = Logger.getLogger("foo.bar");
            for (long i=0; i < nextLong.longValue() + 100 ; i++) {
                if (!goOn) break;
                l = Logger.getLogger("foo.bar.l"+i);
                final ResourceBundle b = l.getResourceBundle();
                final String name = l.getResourceBundleName();
                if (b != null) {
                    if (!name.equals(b.getBaseBundleName())) {
                        throw new RuntimeException("Unexpected bundle name: "
                                +b.getBaseBundleName());
                    }
                }
                Logger ll = Logger.getLogger(l.getName()+".bie.bye");
                ResourceBundle hrb;
                String hrbName;
                if (handler.getLevel() != Level.FINEST) {
                    throw new RuntimeException("Handler level is not finest: "
                            + handler.getLevel());
                }
                final int countBefore = handler.count;
                handler.reset();
                ll.setLevel(Level.FINEST);
                ll.addHandler(handler);
                ll.log(Level.FINE, "dummy {0}", this);
                ll.removeHandler(handler);
                final int countAfter = handler.count;
                if (countBefore == countAfter) {
                    throw new RuntimeException("Handler not called for "
                            + ll.getName() + "("+ countAfter +")");
                }
                hrb = handler.rb;
                hrbName = handler.rbName;
                if (name != null) {
                    // if name is not null, then it implies that it
                    // won't change, since setResourceBundle() cannot
                    // replace a non null name.
                    // Since we never set the resource bundle on 'll',
                    // then ll must inherit its resource bundle [name]
                    // from l - and therefor we should find it in
                    // handler.rb/handler.rbName
                    if (!name.equals(hrbName)) {
                        throw new RuntimeException("Unexpected bundle name: "
                                +hrbName);
                    }
                    // here we know that hrbName is not null so hrb
                    // should not be null either.
                    if (!name.equals(hrb.getBaseBundleName())) {
                        throw new RuntimeException("Unexpected bundle name: "
                                +hrb.getBaseBundleName());
                    }
                }

                // Make sure to refer to 'l' explicitly in order to
                // prevent eager garbage collecting before the end of
                // the test (JDK-8030192)
                if (!ll.getName().startsWith(l.getName())) {
                    throw new RuntimeException("Logger " + ll.getName()
                            + "does not start with expected prefix "
                            + l.getName());
                }

                getRBcount.incrementAndGet();
                if (!goOn) break;
                Thread.sleep(1);
            }
        }
   } catch (Exception x) {
       fail(x);
   }
}
 
源代码8 项目: dragonwell8_jdk   文件: RootLevelInConfigFile.java
private static void testLoggableLevels() {

        Logger foobar = Logger.getLogger("foo.bar");
        if (!foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }

        Logger global = Logger.getGlobal();
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }

        Logger root = Logger.getLogger("");
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }

        root.setLevel(Level.FINER);

        if (foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }
        if (global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }

        if (!foobar.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }

        if (!global.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }

    }
 
源代码9 项目: netty-4.1.22   文件: JdkLogger.java
JdkLogger(Logger logger) {
    super(logger.getName());
    this.logger = logger;
}
 
源代码10 项目: openjdk-8-source   文件: LogWrapperBase.java
protected LogWrapperBase( Logger logger )
{
    this.logger = logger ;
    this.loggerName = logger.getName( );
}
 
源代码11 项目: openjdk-jdk9   文件: RootLevelInConfigFile.java
private static void testLoggableLevels() {

        Logger foobar = Logger.getLogger("foo.bar");
        if (!foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }

        Logger global = Logger.getGlobal();
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }

        Logger root = Logger.getLogger("");
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }

        root.setLevel(Level.FINER);

        if (foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }
        if (global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }

        if (!foobar.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }

        if (!global.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }

    }
 
源代码12 项目: TencentKona-8   文件: RootLevelInConfigFile.java
private static void testLoggableLevels() {

        Logger foobar = Logger.getLogger("foo.bar");
        if (!foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }

        Logger global = Logger.getGlobal();
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }

        Logger root = Logger.getLogger("");
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }

        root.setLevel(Level.FINER);

        if (foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }
        if (global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }

        if (!foobar.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }

        if (!global.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }

    }
 
源代码13 项目: jdk8u_jdk   文件: TestLoggerBundleSync.java
@Override
public void run() {
    try {
        handler.setLevel(Level.FINEST);
        while (goOn) {
            Logger l;
            Logger foo = Logger.getLogger("foo");
            Logger bar = Logger.getLogger("foo.bar");
            for (long i=0; i < nextLong.longValue() + 100 ; i++) {
                if (!goOn) break;
                l = Logger.getLogger("foo.bar.l"+i);
                final ResourceBundle b = l.getResourceBundle();
                final String name = l.getResourceBundleName();
                if (b != null) {
                    if (!name.equals(b.getBaseBundleName())) {
                        throw new RuntimeException("Unexpected bundle name: "
                                +b.getBaseBundleName());
                    }
                }
                Logger ll = Logger.getLogger(l.getName()+".bie.bye");
                ResourceBundle hrb;
                String hrbName;
                if (handler.getLevel() != Level.FINEST) {
                    throw new RuntimeException("Handler level is not finest: "
                            + handler.getLevel());
                }
                final int countBefore = handler.count;
                handler.reset();
                ll.setLevel(Level.FINEST);
                ll.addHandler(handler);
                ll.log(Level.FINE, "dummy {0}", this);
                ll.removeHandler(handler);
                final int countAfter = handler.count;
                if (countBefore == countAfter) {
                    throw new RuntimeException("Handler not called for "
                            + ll.getName() + "("+ countAfter +")");
                }
                hrb = handler.rb;
                hrbName = handler.rbName;
                if (name != null) {
                    // if name is not null, then it implies that it
                    // won't change, since setResourceBundle() cannot
                    // replace a non null name.
                    // Since we never set the resource bundle on 'll',
                    // then ll must inherit its resource bundle [name]
                    // from l - and therefor we should find it in
                    // handler.rb/handler.rbName
                    if (!name.equals(hrbName)) {
                        throw new RuntimeException("Unexpected bundle name: "
                                +hrbName);
                    }
                    // here we know that hrbName is not null so hrb
                    // should not be null either.
                    if (!name.equals(hrb.getBaseBundleName())) {
                        throw new RuntimeException("Unexpected bundle name: "
                                +hrb.getBaseBundleName());
                    }
                }

                // Make sure to refer to 'l' explicitly in order to
                // prevent eager garbage collecting before the end of
                // the test (JDK-8030192)
                if (!ll.getName().startsWith(l.getName())) {
                    throw new RuntimeException("Logger " + ll.getName()
                            + "does not start with expected prefix "
                            + l.getName());
                }

                getRBcount.incrementAndGet();
                if (!goOn) break;
                Thread.sleep(1);
            }
        }
   } catch (Exception x) {
       fail(x);
   }
}
 
源代码14 项目: jdk8u-jdk   文件: RootLevelInConfigFile.java
private static void testLoggableLevels() {

        Logger foobar = Logger.getLogger("foo.bar");
        if (!foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }

        Logger global = Logger.getGlobal();
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }

        Logger root = Logger.getLogger("");
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }

        root.setLevel(Level.FINER);

        if (foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }
        if (global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }

        if (!foobar.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }

        if (!global.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }

    }
 
源代码15 项目: openjdk-jdk8u   文件: TestLoggerBundleSync.java
@Override
public void run() {
    try {
        handler.setLevel(Level.FINEST);
        while (goOn) {
            Logger l;
            Logger foo = Logger.getLogger("foo");
            Logger bar = Logger.getLogger("foo.bar");
            for (long i=0; i < nextLong.longValue() + 100 ; i++) {
                if (!goOn) break;
                l = Logger.getLogger("foo.bar.l"+i);
                final ResourceBundle b = l.getResourceBundle();
                final String name = l.getResourceBundleName();
                if (b != null) {
                    if (!name.equals(b.getBaseBundleName())) {
                        throw new RuntimeException("Unexpected bundle name: "
                                +b.getBaseBundleName());
                    }
                }
                Logger ll = Logger.getLogger(l.getName()+".bie.bye");
                ResourceBundle hrb;
                String hrbName;
                if (handler.getLevel() != Level.FINEST) {
                    throw new RuntimeException("Handler level is not finest: "
                            + handler.getLevel());
                }
                final int countBefore = handler.count;
                handler.reset();
                ll.setLevel(Level.FINEST);
                ll.addHandler(handler);
                ll.log(Level.FINE, "dummy {0}", this);
                ll.removeHandler(handler);
                final int countAfter = handler.count;
                if (countBefore == countAfter) {
                    throw new RuntimeException("Handler not called for "
                            + ll.getName() + "("+ countAfter +")");
                }
                hrb = handler.rb;
                hrbName = handler.rbName;
                if (name != null) {
                    // if name is not null, then it implies that it
                    // won't change, since setResourceBundle() cannot
                    // replace a non null name.
                    // Since we never set the resource bundle on 'll',
                    // then ll must inherit its resource bundle [name]
                    // from l - and therefor we should find it in
                    // handler.rb/handler.rbName
                    if (!name.equals(hrbName)) {
                        throw new RuntimeException("Unexpected bundle name: "
                                +hrbName);
                    }
                    // here we know that hrbName is not null so hrb
                    // should not be null either.
                    if (!name.equals(hrb.getBaseBundleName())) {
                        throw new RuntimeException("Unexpected bundle name: "
                                +hrb.getBaseBundleName());
                    }
                }

                // Make sure to refer to 'l' explicitly in order to
                // prevent eager garbage collecting before the end of
                // the test (JDK-8030192)
                if (!ll.getName().startsWith(l.getName())) {
                    throw new RuntimeException("Logger " + ll.getName()
                            + "does not start with expected prefix "
                            + l.getName());
                }

                getRBcount.incrementAndGet();
                if (!goOn) break;
                Thread.sleep(1);
            }
        }
   } catch (Exception x) {
       fail(x);
   }
}
 
源代码16 项目: jdk8u60   文件: RootLevelInConfigFile.java
private static void testLoggableLevels() {

        Logger foobar = Logger.getLogger("foo.bar");
        if (!foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }

        Logger global = Logger.getGlobal();
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }

        Logger root = Logger.getLogger("");
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }

        root.setLevel(Level.FINER);

        if (foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }
        if (global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }

        if (!foobar.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }

        if (!global.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }

    }
 
源代码17 项目: openjdk-jdk8u-backup   文件: LogWrapperBase.java
protected LogWrapperBase( Logger logger )
{
    this.logger = logger ;
    this.loggerName = logger.getName( );
}
 
源代码18 项目: jdk8u-dev-jdk   文件: RootLevelInConfigFile.java
private static void testLoggableLevels() {

        Logger foobar = Logger.getLogger("foo.bar");
        if (!foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + foobar.getName());
        }

        Logger global = Logger.getGlobal();
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + global.getName());
        }

        Logger root = Logger.getLogger("");
        if (!global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }
        if (!global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Expected FINEST to be loggable in "
                    + root.getName());
        }

        root.setLevel(Level.FINER);

        if (foobar.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (foobar.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + foobar.getName());
        }
        if (global.isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }
        if (global.getParent().isLoggable(Level.FINEST)) {
            throw new RuntimeException("Didn't expect FINEST to be loggable in "
                    + global.getName());
        }

        if (!foobar.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }
        if (!foobar.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + foobar.getName());
        }

        if (!global.isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }
        if (!global.getParent().isLoggable(Level.FINER)) {
            throw new RuntimeException("Expected FINER to be loggable in "
                    + global.getName());
        }

    }
 
源代码19 项目: openjdk-jdk8u   文件: LogWrapperBase.java
protected LogWrapperBase( Logger logger )
{
    this.logger = logger ;
    this.loggerName = logger.getName( );
}
 
源代码20 项目: jdk8u-jdk   文件: TestLoggerBundleSync.java
@Override
public void run() {
    try {
        handler.setLevel(Level.FINEST);
        while (goOn) {
            Logger l;
            Logger foo = Logger.getLogger("foo");
            Logger bar = Logger.getLogger("foo.bar");
            for (long i=0; i < nextLong.longValue() + 100 ; i++) {
                if (!goOn) break;
                l = Logger.getLogger("foo.bar.l"+i);
                final ResourceBundle b = l.getResourceBundle();
                final String name = l.getResourceBundleName();
                if (b != null) {
                    if (!name.equals(b.getBaseBundleName())) {
                        throw new RuntimeException("Unexpected bundle name: "
                                +b.getBaseBundleName());
                    }
                }
                Logger ll = Logger.getLogger(l.getName()+".bie.bye");
                ResourceBundle hrb;
                String hrbName;
                if (handler.getLevel() != Level.FINEST) {
                    throw new RuntimeException("Handler level is not finest: "
                            + handler.getLevel());
                }
                final int countBefore = handler.count;
                handler.reset();
                ll.setLevel(Level.FINEST);
                ll.addHandler(handler);
                ll.log(Level.FINE, "dummy {0}", this);
                ll.removeHandler(handler);
                final int countAfter = handler.count;
                if (countBefore == countAfter) {
                    throw new RuntimeException("Handler not called for "
                            + ll.getName() + "("+ countAfter +")");
                }
                hrb = handler.rb;
                hrbName = handler.rbName;
                if (name != null) {
                    // if name is not null, then it implies that it
                    // won't change, since setResourceBundle() cannot
                    // replace a non null name.
                    // Since we never set the resource bundle on 'll',
                    // then ll must inherit its resource bundle [name]
                    // from l - and therefor we should find it in
                    // handler.rb/handler.rbName
                    if (!name.equals(hrbName)) {
                        throw new RuntimeException("Unexpected bundle name: "
                                +hrbName);
                    }
                    // here we know that hrbName is not null so hrb
                    // should not be null either.
                    if (!name.equals(hrb.getBaseBundleName())) {
                        throw new RuntimeException("Unexpected bundle name: "
                                +hrb.getBaseBundleName());
                    }
                }

                // Make sure to refer to 'l' explicitly in order to
                // prevent eager garbage collecting before the end of
                // the test (JDK-8030192)
                if (!ll.getName().startsWith(l.getName())) {
                    throw new RuntimeException("Logger " + ll.getName()
                            + "does not start with expected prefix "
                            + l.getName());
                }

                getRBcount.incrementAndGet();
                if (!goOn) break;
                Thread.sleep(1);
            }
        }
   } catch (Exception x) {
       fail(x);
   }
}