java.util.logging.Logger.isLoggable()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(12.6k)|赞(0)|评价(0)|浏览(365)

本文整理了Java中java.util.logging.Logger.isLoggable()方法的一些代码示例,展示了Logger.isLoggable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.isLoggable()方法的具体详情如下:
包路径:java.util.logging.Logger
类名称:Logger
方法名:isLoggable

Logger.isLoggable介绍

[英]Check if a message of the given level would actually be logged by this logger. This check is based on the Loggers effective level, which may be inherited from its parent.
[中]

代码示例

代码示例来源:origin: jenkinsci/jenkins

  1. private void notifyRejected(@CheckForNull Class<?> clazz, @CheckForNull String clazzName, String message) {
  2. Throwable cause = null;
  3. if (LOGGER.isLoggable(Level.FINE)) {
  4. cause = new SecurityException("Class rejected by the class filter: " +
  5. (clazz != null ? clazz.getName() : clazzName));
  6. }
  7. LOGGER.log(Level.WARNING, message, cause);
  8. // TODO: add a Telemetry implementation (JEP-304)
  9. }
  10. }

代码示例来源:origin: jenkinsci/jenkins

  1. @Override
  2. public boolean hasPermission(@Nonnull Authentication a, Permission permission) {
  3. if(a==SYSTEM) {
  4. if(LOGGER.isLoggable(FINE))
  5. LOGGER.fine("hasPermission("+a+","+permission+")=>SYSTEM user has full access");
  6. return true;
  7. }
  8. Boolean b = _hasPermission(a,permission);
  9. if(LOGGER.isLoggable(FINE))
  10. LOGGER.fine("hasPermission("+a+","+permission+")=>"+(b==null?"null, thus false":b));
  11. if(b==null) b=false; // default to rejection
  12. return b;
  13. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Releases an allocated or acquired workspace.
  3. */
  4. private synchronized void _release(@Nonnull FilePath p) {
  5. Entry old = inUse.get(p);
  6. if (old==null)
  7. throw new AssertionError("Releasing unallocated workspace "+p);
  8. if (LOGGER.isLoggable(Level.FINE)) {
  9. LOGGER.log(Level.FINE, "releasing " + p + " with lock count " + old.lockCount, new Throwable("from " + this));
  10. }
  11. old.lockCount--;
  12. if (old.lockCount==0)
  13. inUse.remove(p);
  14. notifyAll();
  15. }

代码示例来源:origin: 4thline/cling

  1. protected void addParsedValue(UpnpHeader.Type type, UpnpHeader value) {
  2. if (log.isLoggable(Level.FINE))
  3. log.fine("Adding parsed header: " + value);
  4. List<UpnpHeader> list = parsedHeaders.get(type);
  5. if (list == null) {
  6. list = new LinkedList<>();
  7. parsedHeaders.put(type, list);
  8. }
  9. list.add(value);
  10. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * See {@link #acquire(FilePath,boolean)}
  3. *
  4. * @param context
  5. * Threads that share the same context can re-acquire the same lock (which will just increment the lock count.)
  6. * This allows related executors to share the same workspace.
  7. */
  8. public synchronized Lease acquire(@Nonnull FilePath p, boolean quick, Object context) throws InterruptedException {
  9. Entry e;
  10. Thread t = Thread.currentThread();
  11. String oldName = t.getName();
  12. t.setName("Waiting to acquire "+p+" : "+t.getName());
  13. try {
  14. while (true) {
  15. e = inUse.get(p);
  16. if (e==null || e.context==context)
  17. break;
  18. wait();
  19. }
  20. } finally {
  21. t.setName(oldName);
  22. }
  23. if (LOGGER.isLoggable(Level.FINE)) {
  24. LOGGER.log(Level.FINE, "acquired " + p + (e == null ? "" : " with lock count " + e.lockCount), new Throwable("from " + this));
  25. }
  26. if (e!=null) e.lockCount++;
  27. else inUse.put(p,new Entry(p,quick,context));
  28. return lease(p);
  29. }

代码示例来源:origin: org.netbeans.api/org-openide-util

  1. /**
  2. * Adds a <code>ChangeListener</code> to the listener list. The same
  3. * listener object may be added more than once, and will be called
  4. * as many times as it is added. If <code>listener</code> is null,
  5. * no exception is thrown and no action is taken.
  6. *
  7. * @param listener the <code>ChangeListener</code> to be added.
  8. */
  9. public void addChangeListener(ChangeListener listener) {
  10. if (listener == null) {
  11. return;
  12. }
  13. if (LOG.isLoggable(Level.FINE) && listeners.contains(listener)) {
  14. LOG.log(Level.FINE, "diagnostics for #167491", new IllegalStateException("Added " + listener + " multiply"));
  15. }
  16. listeners.add(listener);
  17. }

代码示例来源:origin: cmusphinx/sphinx4

  1. /**
  2. * Gets or creates a unit from the unit pool
  3. *
  4. * @param name the name of the unit
  5. * @param filler <code>true</code> if the unit is a filler unit
  6. * @param context the context for this unit
  7. * @return the unit
  8. */
  9. public Unit getUnit(String name, boolean filler, Context context) {
  10. Unit unit = ciMap.get(name);
  11. if (context == Context.EMPTY_CONTEXT) {
  12. if (unit == null) {
  13. unit = new Unit(name, filler, nextID++);
  14. ciMap.put(name, unit);
  15. if (logger != null && logger.isLoggable(Level.INFO)) {
  16. logger.info("CI Unit: " + unit);
  17. }
  18. }
  19. } else {
  20. unit = new Unit(unit, filler, context);
  21. }
  22. return unit;
  23. }

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

  1. ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
  2. Node object = (Node) objectHelper.toObject(block.getStructure(blenderContext), blenderContext);
  3. if (LOGGER.isLoggable(Level.FINE)) {
  4. LOGGER.log(Level.FINE, "{0}: {1}--> {2}", new Object[] { object.getName(), object.getLocalTranslation().toString(), object.getParent() == null ? "null" : object.getParent().getName() });
  5. loadedFeatures.objects.add(object);
  6. loadedFeatures.lights.add(((LightNode) object).getLight());
  7. } else if (object instanceof CameraNode && ((CameraNode) object).getCamera() != null) {
  8. loadedFeatures.cameras.add(((CameraNode) object).getCamera());
  9. LOGGER.fine("Only image textures can be loaded as unlinked assets. Generated textures will be applied to an existing object.");
  10. LOGGER.fine("Loading unlinked animations is not yet supported!");
  11. break;
  12. default:
  13. LOGGER.log(Level.FINEST, "Ommiting the block: {0}.", block.getCode());
  14. LOGGER.fine("Baking constraints after every feature is loaded.");
  15. ConstraintHelper constraintHelper = blenderContext.getHelper(ConstraintHelper.class);
  16. constraintHelper.bakeConstraints(blenderContext);
  17. thisFileData.put("scenes", loadedFeatures.scenes == null ? new ArrayList<Object>() : loadedFeatures.scenes);
  18. thisFileData.put("objects", loadedFeatures.objects == null ? new ArrayList<Object>() : loadedFeatures.objects);
  19. thisFileData.put("meshes", loadedFeatures.meshes == null ? new ArrayList<Object>() : loadedFeatures.meshes);
  20. thisFileData.put("materials", loadedFeatures.materials == null ? new ArrayList<Object>() : loadedFeatures.materials);
  21. thisFileData.put("textures", loadedFeatures.textures == null ? new ArrayList<Object>() : loadedFeatures.textures);

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Just record that this workspace is being used, without paying any attention to the synchronization support.
  3. */
  4. public synchronized Lease record(@Nonnull FilePath p) {
  5. if (LOGGER.isLoggable(Level.FINE)) {
  6. LOGGER.log(Level.FINE, "recorded " + p, new Throwable("from " + this));
  7. }
  8. Entry old = inUse.put(p, new Entry(p, false));
  9. if (old!=null)
  10. throw new AssertionError("Tried to record a workspace already owned: "+old);
  11. return lease(p);
  12. }

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

  1. protected void addRemoteObject( byte channel, short objectId, String name, ClassInfo typeInfo ) {
  2. if( log.isLoggable(Level.FINEST) ) {
  3. log.finest("addRemoveObject(" + objectId + ", " + name + ", " + typeInfo + ")");
  4. }
  5. remote.lock.writeLock().lock();
  6. try {
  7. Object existing = remote.byName.get(name);
  8. if( existing != null ) {
  9. throw new RuntimeException("Object already registered for:" + name);
  10. }
  11. RemoteObjectHandler remoteHandler = new RemoteObjectHandler(this, channel, objectId, typeInfo);
  12. Object remoteObject = Proxy.newProxyInstance(getClass().getClassLoader(),
  13. new Class[] {typeInfo.getType()},
  14. remoteHandler);
  15. remote.byName.put(name, remoteObject);
  16. remote.byId.put(objectId, remoteObject);
  17. } finally {
  18. remote.lock.writeLock().unlock();
  19. }
  20. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Gets the information about the queue item for the given project.
  3. *
  4. * @return null if the project is not in the queue.
  5. * @since 1.607
  6. */
  7. private List<Item> liveGetItems(Task t) {
  8. lock.lock();
  9. try {
  10. List<Item> result = new ArrayList<Item>();
  11. result.addAll(blockedProjects.getAll(t));
  12. result.addAll(buildables.getAll(t));
  13. // Do not include pendings—we have already finalized WorkUnitContext.actions.
  14. if (LOGGER.isLoggable(Level.FINE)) {
  15. List<BuildableItem> thePendings = pendings.getAll(t);
  16. if (!thePendings.isEmpty()) {
  17. LOGGER.log(Level.FINE, "ignoring {0} during scheduleInternal", thePendings);
  18. }
  19. }
  20. for (Item item : waitingList) {
  21. if (item.task.equals(t)) {
  22. result.add(item);
  23. }
  24. }
  25. return result;
  26. } finally {
  27. lock.unlock();
  28. }
  29. }

代码示例来源:origin: jenkinsci/jenkins

  1. if (node == null)
  2. continue; // this computer is gone
  3. byName.put(node.getNodeName(),c);
  4. long start = System.currentTimeMillis();
  5. updateComputer(s, byName, used, automaticSlaveLaunch);
  6. if (LOG_STARTUP_PERFORMANCE && LOGGER.isLoggable(Level.FINE)) {
  7. LOGGER.fine(String.format("Took %dms to update node %s",
  8. System.currentTimeMillis() - start, s.getNodeName()));

代码示例来源:origin: jenkinsci/jenkins

  1. if (LOGGER.isLoggable(Level.FINE)) {
  2. LOGGER.fine("Determining visibility of " + d + " in contexts of type " + contextClass);
  3. if (LOGGER.isLoggable(Level.FINER)) {
  4. LOGGER.finer("Querying " + f + " for visibility of " + d + " in type " + contextClass);
  5. if (LOGGER.isLoggable(Level.CONFIG)) {
  6. LOGGER.config("Filter " + f + " hides " + d + " in contexts of type " + contextClass);
  7. LOGGER.log(Level.WARNING,
  8. "Encountered error while processing filter " + f + " for contexts of type " + contextClass, e);
  9. throw e;
  10. } catch (Throwable e) {
  11. LOGGER.log(logLevelFor(f), "Uncaught exception from filter " + f + " for context of type " + contextClass, e);
  12. continue OUTER; // veto-ed. not shown
  13. r.add(d);

代码示例来源:origin: stanfordnlp/CoreNLP

  1. public List<String> annotateMulticlass(List<Datum<String, String>> testDatums) {
  2. List<String> predictedLabels = new ArrayList<>();
  3. for (Datum<String, String> testDatum: testDatums) {
  4. String label = classOf(testDatum, null);
  5. Counter<String> probs = probabilityOf(testDatum);
  6. double prob = probs.getCount(label);
  7. StringWriter sw = new StringWriter();
  8. PrintWriter pw = new PrintWriter(sw);
  9. if (logger.isLoggable(Level.FINE)) {
  10. justificationOf(testDatum, pw, label);
  11. }
  12. logger.fine("JUSTIFICATION for label GOLD:" + testDatum.label() + " SYS:" + label + " (prob:" + prob + "):\n"
  13. + sw.toString() + "\nJustification done.");
  14. predictedLabels.add(label);
  15. if(! testDatum.label().equals(label)){
  16. logger.info("Classification: found different type " + label + " for relation: " + testDatum);
  17. } else{
  18. logger.info("Classification: found similar type " + label + " for relation: " + testDatum);
  19. }
  20. }
  21. return predictedLabels;
  22. }

代码示例来源:origin: igniterealtime/Smack

  1. if (LOGGER.isLoggable(Level.FINE)) {
  2. String logMessage = "Resolved SRV RR for " + srvDomain + ":";
  3. for (SRVRecord r : srvRecords)
  4. logMessage += " " + r;
  5. LOGGER.fine(logMessage);
  6. addresses.add(hostAddress);

代码示例来源:origin: geoserver/geoserver

  1. URL resource = resources.nextElement();
  2. if (LOGGER.isLoggable(Level.FINE))
  3. LOGGER.fine("Loading resources: " + resource.getFile());
  4. manifests.put(resource.getPath(), new Manifest(is));
  5. LOGGER.log(
  6. java.util.logging.Level.SEVERE,
  7. "Error loading resources file: " + e.getLocalizedMessage(),
  8. LOGGER.log(
  9. java.util.logging.Level.SEVERE,
  10. "Error loading resources file: " + e.getLocalizedMessage(),

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

  1. if( log.isLoggable(Level.FINEST) ) {
  2. log.log(Level.FINEST, "map({0})", constraints);
  3. if( log.isLoggable(Level.FINEST) ) {
  4. log.log(Level.FINEST, "Checking method:{0}", m);
  5. log.finest("Name is not allowed.");
  6. continue;
  7. log.finest("Name is not in constraints set.");
  8. continue;
  9. if( log.isLoggable(Level.FINEST) ) {
  10. log.log(Level.FINEST, "Adding method mapping:{0} = {1}", new Object[]{getMessageType(m), m});
  11. methods.put(getMessageType(m), m);

代码示例来源:origin: cmusphinx/sphinx4

  1. /**
  2. * Gets the best token for this state
  3. *
  4. * @param state the state of interest
  5. * @return the best token
  6. */
  7. protected Token getBestToken(SearchState state) {
  8. Token best = bestTokenMap.get(state);
  9. if (logger.isLoggable(Level.FINER) && best != null) {
  10. logger.finer("BT " + best + " for state " + state);
  11. }
  12. return best;
  13. }

代码示例来源:origin: jersey/jersey

  1. private static Object getLegacyFallbackValue(Map<String, ?> properties, Map<String, String> legacyFallbackMap, String key) {
  2. if (legacyFallbackMap == null || !legacyFallbackMap.containsKey(key)) {
  3. return null;
  4. }
  5. String fallbackKey = legacyFallbackMap.get(key);
  6. Object value = properties.get(fallbackKey);
  7. if (value != null && LOGGER.isLoggable(Level.CONFIG)) {
  8. LOGGER.config(LocalizationMessages.PROPERTIES_HELPER_DEPRECATED_PROPERTY_NAME(fallbackKey, key));
  9. }
  10. return value;
  11. }

代码示例来源:origin: jenkinsci/jenkins

  1. public synchronized List<String> getArguments() {
  2. if(arguments!=null)
  3. return arguments;
  4. arguments = new ArrayList<String>(argc);
  5. if (argc == 0) {
  6. return arguments;
  7. }
  8. int psize = b64 ? 8 : 4;
  9. Memory m = new Memory(psize);
  10. try {
  11. if(LOGGER.isLoggable(FINER))
  12. LOGGER.finer("Reading "+getFile("as"));
  13. int fd = LIBC.open(getFile("as").getAbsolutePath(), 0);
  14. try {
  15. for( int n=0; n<argc; n++ ) {
  16. // read a pointer to one entry
  17. LIBC.pread(fd, m, new NativeLong(psize), new NativeLong(argp+n*psize));
  18. long addr = b64 ? m.getLong(0) : to64(m.getInt(0));
  19. arguments.add(readLine(fd, addr, "argv["+ n +"]"));
  20. }
  21. } finally {
  22. LIBC.close(fd);
  23. }
  24. } catch (IOException | LastErrorException e) {
  25. // failed to read. this can happen under normal circumstances (most notably permission denied)
  26. // so don't report this as an error.
  27. }
  28. arguments = Collections.unmodifiableList(arguments);
  29. return arguments;
  30. }

相关文章