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

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

本文整理了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

private void notifyRejected(@CheckForNull Class<?> clazz, @CheckForNull String clazzName, String message) {
    Throwable cause = null;
    if (LOGGER.isLoggable(Level.FINE)) {
      cause = new SecurityException("Class rejected by the class filter: " +
          (clazz != null ? clazz.getName() : clazzName));
    }
    LOGGER.log(Level.WARNING, message, cause);

    // TODO: add a Telemetry implementation (JEP-304)
  }
}

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

@Override
public boolean hasPermission(@Nonnull Authentication a, Permission permission) {
  if(a==SYSTEM) {
    if(LOGGER.isLoggable(FINE))
      LOGGER.fine("hasPermission("+a+","+permission+")=>SYSTEM user has full access");
    return true;
  }
  Boolean b = _hasPermission(a,permission);
  if(LOGGER.isLoggable(FINE))
    LOGGER.fine("hasPermission("+a+","+permission+")=>"+(b==null?"null, thus false":b));
  if(b==null) b=false;    // default to rejection
  return b;
}

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

/**
 * Releases an allocated or acquired workspace.
 */
private synchronized void _release(@Nonnull FilePath p) {
  Entry old = inUse.get(p);
  if (old==null)
    throw new AssertionError("Releasing unallocated workspace "+p);
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "releasing " + p + " with lock count " + old.lockCount, new Throwable("from " + this));
  }
  old.lockCount--;
  if (old.lockCount==0)
    inUse.remove(p);
  notifyAll();
}

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

protected void addParsedValue(UpnpHeader.Type type, UpnpHeader value) {
  if (log.isLoggable(Level.FINE))
    log.fine("Adding parsed header: " + value);
  List<UpnpHeader> list = parsedHeaders.get(type);
  if (list == null) {
    list = new LinkedList<>();
    parsedHeaders.put(type, list);
  }
  list.add(value);
}

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

/**
 * See {@link #acquire(FilePath,boolean)}
 *
 * @param context
 *      Threads that share the same context can re-acquire the same lock (which will just increment the lock count.)
 *      This allows related executors to share the same workspace.
 */
public synchronized Lease acquire(@Nonnull FilePath p, boolean quick, Object context) throws InterruptedException {
  Entry e;
  Thread t = Thread.currentThread();
  String oldName = t.getName();
  t.setName("Waiting to acquire "+p+" : "+t.getName());
  try {
    while (true) {
      e = inUse.get(p);
      if (e==null || e.context==context)
        break;
      wait();
    }
  } finally {
    t.setName(oldName);
  }
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "acquired " + p + (e == null ? "" : " with lock count " + e.lockCount), new Throwable("from " + this));
  }
  
  if (e!=null)    e.lockCount++;
  else            inUse.put(p,new Entry(p,quick,context));
  return lease(p);
}

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

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

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

/**
 * Gets or creates a unit from the unit pool
 *
 * @param name    the name of the unit
 * @param filler  <code>true</code> if the unit is a filler unit
 * @param context the context for this unit
 * @return the unit
 */
public Unit getUnit(String name, boolean filler, Context context) {
  Unit unit = ciMap.get(name);
  if (context == Context.EMPTY_CONTEXT) {
    if (unit == null) {
      unit = new Unit(name, filler, nextID++);
      ciMap.put(name, unit);
      if (logger != null && logger.isLoggable(Level.INFO)) {
        logger.info("CI Unit: " + unit);
      }
    }
  } else {
    unit = new Unit(unit, filler, context);
  }
  return unit;
}

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

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

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

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

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

protected void addRemoteObject( byte channel, short objectId, String name, ClassInfo typeInfo ) {
  if( log.isLoggable(Level.FINEST) ) {
    log.finest("addRemoveObject(" + objectId + ", " + name + ", " + typeInfo + ")");
  }
  remote.lock.writeLock().lock();
  try {
    Object existing = remote.byName.get(name);
    if( existing != null ) {
      throw new RuntimeException("Object already registered for:" + name);
    }
    
    RemoteObjectHandler remoteHandler = new RemoteObjectHandler(this, channel, objectId, typeInfo);
    Object remoteObject = Proxy.newProxyInstance(getClass().getClassLoader(),
                           new Class[] {typeInfo.getType()},
                           remoteHandler);
                                
    remote.byName.put(name, remoteObject); 
    remote.byId.put(objectId, remoteObject);
  } finally {
    remote.lock.writeLock().unlock();
  } 
}

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

/**
 * Gets the information about the queue item for the given project.
 *
 * @return null if the project is not in the queue.
 * @since 1.607
 */
private List<Item> liveGetItems(Task t) {
  lock.lock();
  try {
    List<Item> result = new ArrayList<Item>();
    result.addAll(blockedProjects.getAll(t));
    result.addAll(buildables.getAll(t));
    // Do not include pendings—we have already finalized WorkUnitContext.actions.
    if (LOGGER.isLoggable(Level.FINE)) {
      List<BuildableItem> thePendings = pendings.getAll(t);
      if (!thePendings.isEmpty()) {
        LOGGER.log(Level.FINE, "ignoring {0} during scheduleInternal", thePendings);
      }
    }
    for (Item item : waitingList) {
      if (item.task.equals(t)) {
        result.add(item);
      }
    }
    return result;
  } finally {
    lock.unlock();
  }
}

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

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

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

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

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

public List<String> annotateMulticlass(List<Datum<String, String>> testDatums) {
 List<String> predictedLabels = new ArrayList<>();
 for (Datum<String, String> testDatum: testDatums) {
  String label = classOf(testDatum, null);
  Counter<String> probs = probabilityOf(testDatum);
  double prob = probs.getCount(label);
  StringWriter sw = new StringWriter();
  PrintWriter pw = new PrintWriter(sw);
  if (logger.isLoggable(Level.FINE)) {
   justificationOf(testDatum, pw, label);
  }
  logger.fine("JUSTIFICATION for label GOLD:" + testDatum.label() + " SYS:" + label + " (prob:" + prob + "):\n"
      + sw.toString() + "\nJustification done.");
  predictedLabels.add(label);
  if(! testDatum.label().equals(label)){
   logger.info("Classification: found different type " + label + " for relation: " + testDatum);
  } else{
   logger.info("Classification: found similar type " + label + " for relation: " + testDatum);
  }
 }
 return predictedLabels;
}

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

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

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

URL resource = resources.nextElement();
    if (LOGGER.isLoggable(Level.FINE))
      LOGGER.fine("Loading resources: " + resource.getFile());
    manifests.put(resource.getPath(), new Manifest(is));
    LOGGER.log(
        java.util.logging.Level.SEVERE,
        "Error loading resources file: " + e.getLocalizedMessage(),
LOGGER.log(
    java.util.logging.Level.SEVERE,
    "Error loading resources file: " + e.getLocalizedMessage(),

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

if( log.isLoggable(Level.FINEST) ) {
  log.log(Level.FINEST, "map({0})", constraints);
  if( log.isLoggable(Level.FINEST) ) {
    log.log(Level.FINEST, "Checking method:{0}", m);
    log.finest("Name is not allowed.");
    continue;
    log.finest("Name is not in constraints set.");
    continue;
    if( log.isLoggable(Level.FINEST) ) {
      log.log(Level.FINEST, "Adding method mapping:{0} = {1}", new Object[]{getMessageType(m), m});
    methods.put(getMessageType(m), m);

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

/**
 * Gets the best token for this state
 *
 * @param state the state of interest
 * @return the best token
 */
protected Token getBestToken(SearchState state) {
  Token best = bestTokenMap.get(state);
  if (logger.isLoggable(Level.FINER) && best != null) {
    logger.finer("BT " + best + " for state " + state);
  }
  return best;
}

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

private static Object getLegacyFallbackValue(Map<String, ?> properties, Map<String, String> legacyFallbackMap, String key) {
  if (legacyFallbackMap == null || !legacyFallbackMap.containsKey(key)) {
    return null;
  }
  String fallbackKey = legacyFallbackMap.get(key);
  Object value = properties.get(fallbackKey);
  if (value != null && LOGGER.isLoggable(Level.CONFIG)) {
    LOGGER.config(LocalizationMessages.PROPERTIES_HELPER_DEPRECATED_PROPERTY_NAME(fallbackKey, key));
  }
  return value;
}

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

public synchronized List<String> getArguments() {
    if(arguments!=null)
      return arguments;
    arguments = new ArrayList<String>(argc);
if (argc == 0) {
  return arguments;
}
    int psize = b64 ? 8 : 4;
    Memory m = new Memory(psize);
    try {
      if(LOGGER.isLoggable(FINER))
        LOGGER.finer("Reading "+getFile("as"));
      int fd = LIBC.open(getFile("as").getAbsolutePath(), 0);
      try {
        for( int n=0; n<argc; n++ ) {
          // read a pointer to one entry
          LIBC.pread(fd, m, new NativeLong(psize), new NativeLong(argp+n*psize));
          long addr = b64 ? m.getLong(0) : to64(m.getInt(0));
          arguments.add(readLine(fd, addr, "argv["+ n +"]"));
        }
      } finally {
        LIBC.close(fd);
      }
    } catch (IOException | LastErrorException e) {
      // failed to read. this can happen under normal circumstances (most notably permission denied)
      // so don't report this as an error.
    }
    arguments = Collections.unmodifiableList(arguments);
    return arguments;
  }

相关文章