当前位置: 首页>>代码示例>>Java>>正文


Java Logger.isLoggable方法代码示例

本文整理汇总了Java中java.util.logging.Logger.isLoggable方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.isLoggable方法的具体用法?Java Logger.isLoggable怎么用?Java Logger.isLoggable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.logging.Logger的用法示例。


在下文中一共展示了Logger.isLoggable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
public void execute() throws CoreException, IOException, MalformedURLException {
    Logger log = Logger.getLogger(this.getClass().getName());
    if(log.isLoggable(Level.FINE)) {
        log.log(Level.FINE, "executing GetTaskDataCommand for attachment id: {0}", ta.getValue()); // NOI18N
    }
    AbstractTaskAttachmentHandler taskAttachmentHandler = repositoryConnector.getTaskAttachmentHandler();
    if (!taskAttachmentHandler.canGetContent(taskRepository, task)) {
        throw new IOException("Cannot get content for attachment with id: " + ta.getValue());
    }
    InputStream is = taskAttachmentHandler.getContent(taskRepository, task, ta, new NullProgressMonitor());
    try {
        byte [] buffer = new byte[4096];
        int n;
        while ((n = is.read(buffer)) != -1) {
            os.write(buffer, 0, n);
        }
    } finally {
        is.close();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:GetAttachmentCommand.java

示例2: execute

import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
public void execute() throws CoreException {
    
    Logger log = Logger.getLogger(this.getClass().getName());
    if(log.isLoggable(Level.FINE)) {
        log.log(
            Level.FINE, 
            "executing GetMultiTaskDataCommand for tasks: {0}", // NOI18N
            print(ids));    
    }
    
    repositoryConnector.getTaskDataHandler().getMultiTaskData(
            taskRepository,
            ids,
            collector,
            new NullProgressMonitor());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:GetMultiTaskDataCommand.java

示例3: randomFloat

import java.util.logging.Logger; //导入方法依赖的package包/类
/**
 * Convenience to aid logging uses of Randoms.
 *
 * @param logger The {@code Logger} to log to.
 * @param logMe A string to log with the result.
 * @param random A pseudo-{@code Random} number source.
 * @return A pseudo-random double r, 0 ≤ r < 1.0.
 */
public static float randomFloat(Logger logger, String logMe,
                                Random random) {
    float ret = random.nextFloat();
    if (logger != null && logger.isLoggable(Level.FINEST)) {
        logger.finest(logMe + " random(1.0f) = " + ret);
    }
    return ret;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:17,代码来源:RandomUtils.java

示例4: prepare

import java.util.logging.Logger; //导入方法依赖的package包/类
/** Collects and returns a set of refactoring elements - objects that
 * will be affected by the refactoring.
 * @param session RefactoringSession that the operation will use to return
 * instances of {@link org.netbeans.modules.refactoring.api.RefactoringElement} class representing objects that
 * will be affected by the refactoring.
 * @return Chain of problems encountered or <code>null</code> in no problems
 * were found.
 */
@CheckForNull
public final Problem prepare(@NonNull RefactoringSession session) {
    try {
        Parameters.notNull("session", session); // NOI18N
        long time = System.currentTimeMillis();

        Problem p = null;
        boolean checkCalled = false;
        if (currentState < PARAMETERS_CHECK) {
            p = checkParameters();
            checkCalled = true;
        }
        if (p != null && p.isFatal()) {
            return p;
        }

        p = pluginsPrepare(checkCalled ? p : null, session);
        Logger timer = Logger.getLogger("TIMER.RefactoringPrepare");
        if (timer.isLoggable(Level.FINE)) {
            time = System.currentTimeMillis() - time;
            timer.log(Level.FINE, "refactoring.prepare", new Object[]{this, time});
        }
        return p;
    } finally {
        session.finished();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:AbstractRefactoring.java

示例5: handleException

import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
public void handleException(Throwable exception, SubscriberExceptionContext context) {
  Logger logger = logger(context);
  if (logger.isLoggable(Level.SEVERE)) {
    logger.log(Level.SEVERE, message(context), exception);
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:8,代码来源:EventBus.java

示例6: execute

import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
public void execute() throws CoreException, IOException, MalformedURLException {
    Logger log = Logger.getLogger(this.getClass().getName());
    if(log.isLoggable(Level.FINE)) {
        log.log(Level.FINE, "executing PostTaskDataCommand for task: {0}", task.getTaskId()); // NOI18N
    }
    AbstractTaskAttachmentHandler taskAttachmentHandler = repositoryConnector.getTaskAttachmentHandler();
    if (!taskAttachmentHandler.canPostContent(taskRepository, task)) {
        throw new IOException("Cannot post attachment for task with id: " + task.getTaskId());
    }
    taskAttachmentHandler.postContent(taskRepository, task, taskAttachmentSource, comment, attAttribute, new NullProgressMonitor());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:PostAttachmentCommand.java

示例7: execute

import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
public void execute () throws CoreException, IOException, MalformedURLException {
    Logger log = Logger.getLogger(this.getClass().getName());
    if (log.isLoggable(Level.FINE)) {
        log.log(
                Level.FINE,
                "executing GetRepositoryTasksCommand for task ids {0}:{1}", //NOI18N
                new Object[] { taskRepository.getUrl(), taskIds });
    }
    if (taskIds.size() == 1 || !connector.getTaskDataHandler().canGetMultiTaskData(taskRepository)) {
        for (String taskId : taskIds) {
            TaskData taskData = connector.getTaskData(taskRepository, taskId, monitor);
            if (monitor.isCanceled()) {
                return;
            }
            if (taskData != null) {
                Accessor acc = Accessor.getInstance();
                NbTask task = acc.getOrCreateTask(taskRepository, taskData.getTaskId(), true);
                taskDataManager.putUpdatedTaskData(acc.getDelegate(task), taskData, true);
                tasks.add(task);
            }
        }
    } else {
        connector.getTaskDataHandler().getMultiTaskData(taskRepository, taskIds,
                new Collector(), monitor);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:GetRepositoryTasksCommand.java

示例8: notifySafe

import java.util.logging.Logger; //导入方法依赖的package包/类
/**
 * Calls notifier.notify() on each of the stored listeners, allowing you to execute stored
 * command.
 * <p><p>
 * Every notification is run inside try/catch block, exceptions are reported into the log
 * (if not null) and method returns false if some exception is thrown.
 * 
 * @param notifier
 * @param exceptionLog where to log exceptions, may be null
 * @return true, if no exception happened
 */
public boolean notifySafe(ListenerNotifier<Listener> notifier, Logger exceptionLog) {
	
	boolean noException = true;
	
	synchronized(listeners) {
		boolean listenersIterationOriginal = listenersIteration;
		listenersIteration = true;
		try {
 		Iterator<ListenerStore<Listener>> iterator = listeners.iterator();
 		while(iterator.hasNext()) {
 			ListenerStore<Listener> store = iterator.next();
 			Listener storedListener = store.getListener();
 			if (storedListener == null) {
 				if (!listenersIterationOriginal) {
 					if ((store instanceof WeakListenerStore) && log != null && log.isLoggable(Level.FINE)) {
 						log.fine((name == null ? "" : name + ": ") + "Weakly referenced listener was GC()ed.");
 					}
 					iterator.remove();
 				}
 				continue;
 			}
 			try {
 				notifier.notify(storedListener);
 			} catch (Exception e) {
 				noException = false;
 				if (exceptionLog != null) {
 					if (exceptionLog.isLoggable(Level.SEVERE)) exceptionLog.severe(ExceptionToString.process("Exception during event processing (" + notifier.getEvent() + ").", e));
 				}
 			}
 		}
		} finally {
			listenersIteration = listenersIterationOriginal;
		}
	}
	
	return noException;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:49,代码来源:Listeners.java

示例9: execute

import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
public void execute () throws CoreException {
    final Logger log = Logger.getLogger(this.getClass().getName());
    if (log.isLoggable(Level.FINE)) {
        Map<String, String> attrs = query.getAttributes();
        log.log(
                Level.FINE,
                "executing SimpleQueryCommand for query {0} on repository {1} with url \n\t{2} and parameters \n\t{3}", // NOI18N
                new Object[]{query.getSummary(), taskRepository.getUrl(), query.getUrl(), attrs != null ? attrs : null});
    }
    TaskDataCollector collector = new TaskDataCollector() {
        @Override
        public void accept (TaskData taskData) {
            try {
                Accessor acc = Accessor.getInstance();
                NbTask task = acc.getOrCreateTask(taskRepository, taskData.getTaskId(), true);
                taskDataManager.putUpdatedTaskData(acc.getDelegate(task), taskData, true);
                tasks.add(task);
            } catch (CoreException ex) {
                log.log(Level.INFO, "Cannot save task data " + taskData.getTaskId(), ex);
            }
        }
    };
    status = repositoryConnector.performQuery(taskRepository, query, collector, new SynchronizationSession(), monitor);
    if (status != null && status.getSeverity() == IStatus.ERROR) {
        if (status.getException() instanceof CoreException) {
            throw (CoreException) status.getException();
        } else {
            throw new CoreException(status);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:SimpleQueryCommand.java

示例10: randomDouble

import java.util.logging.Logger; //导入方法依赖的package包/类
/**
 * Convenience to aid logging uses of Randoms.
 *
 * @param logger The {@code Logger} to log to.
 * @param logMe A string to log with the result.
 * @param random A pseudo-{@code Random} number source.
 * @return A pseudo-random double r, 0 &le; r &lt; 1.0.
 */
public static double randomDouble(Logger logger, String logMe,
                                  Random random) {
    double ret = random.nextDouble();
    if (logger != null && logger.isLoggable(Level.FINEST)) {
        logger.finest(logMe + " random(1.0) = " + ret);
    }
    return ret;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:17,代码来源:RandomUtils.java

示例11: execute

import java.util.logging.Logger; //导入方法依赖的package包/类
@Override
public void execute() throws CoreException, IOException, MalformedURLException {
    
    Logger log = Logger.getLogger(this.getClass().getName());
    if(log.isLoggable(Level.FINE)) {
        log.log(
            Level.FINE, 
            "executing SubmitCommand for taskData with id {0} ", // NOI18N
            data.getTaskId());
    }
    
    rr = repositoryConnector.getTaskDataHandler().postTaskData(taskRepository, data, null, new NullProgressMonitor());
    // XXX evaluate rr
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:SubmitCommand.java

示例12: randomShuffle

import java.util.logging.Logger; //导入方法依赖的package包/类
/**
 * Shuffle a list.
 *
 * @param logger The {@code Logger} to log to.
 * @param logMe A string to log with the result.
 * @param list The list.
 * @param random A random number source.
 */
public static void randomShuffle(Logger logger, String logMe,
                                 List<?> list, Random random) {
    if (list.size() <= 1 || random == null) return;
    if (logger != null && logger.isLoggable(Level.FINEST)) {
        logger.finest(logMe + " shuffle.");
    }
    Collections.shuffle(list, random);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:17,代码来源:RandomUtils.java

示例13: reportIndexerStatistics

import java.util.logging.Logger; //导入方法依赖的package包/类
private static void reportIndexerStatistics(
        final @NonNull Logger logger,
        final @NonNull Level level,
        final @NonNull Object[] data) {
    if (logger.isLoggable(level)) {
        final LogRecord r = new LogRecord(level, "INDEXING_FINISHED"); //NOI18N
        r.setParameters(data);
        r.setResourceBundle(NbBundle.getBundle(RepositoryUpdater.class));
        r.setResourceBundleName(RepositoryUpdater.class.getPackage().getName() + ".Bundle"); //NOI18N
        r.setLoggerName(logger.getName());
        logger.log(r);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:RepositoryUpdater.java

示例14: logError

import java.util.logging.Logger; //导入方法依赖的package包/类
public static void logError(final Level logLevel, final Logger log, final Process p) throws IOException {
    if (log != null && log.isLoggable(logLevel)) {
        logErrorImpl(logLevel, log, readProcessError(p));
    } else {
        readAndIgnoreProcessStream(p.getErrorStream());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:ProcessUtils.java

示例15: isDebugOn

import java.util.logging.Logger; //导入方法依赖的package包/类
public boolean isDebugOn() {
    final Logger l = getLogger();
    if (l==null) return false;
    return l.isLoggable(Level.FINEST);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:MibLogger.java


注:本文中的java.util.logging.Logger.isLoggable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。