Java Code Examples for org.apache.commons.logging.Log#debug()
The following examples show how to use
org.apache.commons.logging.Log#debug() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassMap.java From commons-jexl with Apache License 2.0 | 6 votes |
/** * Recurses up class hierarchy to get all super classes. * @param cache the cache to fill * @param permissions the permissions to apply during introspection * @param clazz the class to populate the cache from * @param log the Log */ private static void populateWithClass(ClassMap cache, Permissions permissions, Class<?> clazz, Log log) { try { Method[] methods = clazz.getDeclaredMethods(); for (Method mi : methods) { // add method to byKey cache; do not override MethodKey key = new MethodKey(mi); Method pmi = cache.byKey.putIfAbsent(key, permissions.allow(mi) ? mi : CACHE_MISS); if (pmi != null && pmi != CACHE_MISS && log.isDebugEnabled() && !key.equals(new MethodKey(pmi))) { // foo(int) and foo(Integer) have the same signature for JEXL log.debug("Method " + pmi + " is already registered, key: " + key.debugString()); } } } catch (SecurityException se) { // Everybody feels better with... if (log.isDebugEnabled()) { log.debug("While accessing methods of " + clazz + ": ", se); } } }
Example 2
Source File: ConfigFileFinder.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
public boolean readFile(Reader reader, String readFrom, String path, String baseUrl, Log log) { // At the moment it is assumed the file is Json, but that does not need to be the case. // We have the path including extension. boolean successReadingConfig = true; try { JsonNode jsonNode = jsonObjectMapper.readValue(reader, JsonNode.class); String readFromMessage = readFrom + ' ' + path; if (log.isTraceEnabled()) { log.trace(readFromMessage + " config is: " + jsonNode); } else { log.debug(readFromMessage + " config read"); } readJson(jsonNode, readFromMessage, baseUrl); } catch (Exception e) { log.error("Error reading "+path, e); successReadingConfig = false; } return successReadingConfig; }
Example 3
Source File: AJExtender.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Logs each method routing path once per session. * * @param logger * @param route */ static void oneTimeLiveLog(Log logger, ExtensionRoute route) { synchronized (AJExtender.class) { if (oneTimeLogSet == null) { oneTimeLogSet = ConcurrentHashMap.newKeySet(); } } synchronized (oneTimeLogSet) { if (oneTimeLogSet.contains(route)) { return; } else { logger.debug(route.toString()); oneTimeLogSet.add(route); } } }
Example 4
Source File: RemoteParForUtils.java From systemds with Apache License 2.0 | 6 votes |
public static LocalVariableMap[] getResults(List<Tuple2<Long,String>> out, Log LOG ) { HashMap<Long,LocalVariableMap> tmp = new HashMap<>(); int countAll = 0; for( Tuple2<Long,String> entry : out ) { Long key = entry._1(); String val = entry._2(); if( !tmp.containsKey( key ) ) tmp.put(key, new LocalVariableMap()); Object[] dat = ProgramConverter.parseDataObject( val ); tmp.get(key).put((String)dat[0], (Data)dat[1]); countAll++; } if( LOG != null ) { LOG.debug("Num remote worker results (before deduplication): "+countAll); LOG.debug("Num remote worker results: "+tmp.size()); } //create return array return tmp.values().toArray(new LocalVariableMap[0]); }
Example 5
Source File: Declaration.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Attempt to load custom rules for the target class at the specified * pattern. * <p> * On return, any custom rules associated with the plugin class have * been loaded into the Rules object currently associated with the * specified digester object. */ public void configure(Digester digester, String pattern) throws PluginException { Log log = digester.getLogger(); boolean debug = log.isDebugEnabled(); if (debug) { log.debug("configure being called!"); } if (!initialized) { throw new PluginAssertionFailure("Not initialized."); } if (ruleLoader != null) { ruleLoader.addRules(digester, pattern); } }
Example 6
Source File: RestService.java From elasticsearch-hadoop with Apache License 2.0 | 5 votes |
/** * Creates a RestRepository for use with a multi-index resource pattern. The client is left pinned * to the original node that it was pinned to since the shard locations cannot be determined at all. * @param settings Job settings * @param currentInstance Partition number * @param resource Configured write resource * @param log Logger to use * @return The RestRepository to be used by the partition writer */ private static RestRepository initMultiIndices(Settings settings, long currentInstance, Resource resource, Log log) { if (log.isDebugEnabled()) { log.debug(String.format("Resource [%s] resolves as an index pattern", resource)); } // multi-index write - since we don't know before hand what index will be used, use an already selected node String node = SettingsUtils.getPinnedNode(settings); if (log.isDebugEnabled()) { log.debug(String.format("Partition writer instance [%s] assigned to [%s]", currentInstance, node)); } return new RestRepository(settings); }
Example 7
Source File: TransformActionExecuter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean onLogException(Log logger, Throwable t, String message) { if (t instanceof UnimportantTransformException ) { logger.debug(message); return true; } else if (t instanceof UnsupportedTransformationException) { logger.error(message); return true; } return false; }
Example 8
Source File: LoaderSetProperties.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Just add a SetPropertiesRule at the specified path. */ @Override public void addRules(Digester digester, String path) { Log log = digester.getLogger(); boolean debug = log.isDebugEnabled(); if (debug) { log.debug( "LoaderSetProperties loading rules for plugin at path [" + path + "]"); } digester.addSetProperties(path); }
Example 9
Source File: InitializationUtils.java From elasticsearch-hadoop with Apache License 2.0 | 5 votes |
public static boolean setFieldExtractorIfNotSet(Settings settings, Class<? extends FieldExtractor> clazz, Log log) { if (!StringUtils.hasText(settings.getMappingIdExtractorClassName())) { Log logger = (log != null ? log : LogFactory.getLog(clazz)); String name = clazz.getName(); settings.setProperty(ConfigurationOptions.ES_MAPPING_DEFAULT_EXTRACTOR_CLASS, name); if (logger.isDebugEnabled()) { logger.debug(String.format("Using pre-defined field extractor [%s] as default", settings.getMappingIdExtractorClassName())); } return true; } return false; }
Example 10
Source File: FileUtil.java From tajo with Apache License 2.0 | 5 votes |
/** * Close the Closeable objects and <b>ignore</b> any {@link IOException} or * null pointers. Must only be used for cleanup in exception handlers. * * @param log the log to record problems to at debug level. Can be null. * @param closeables the objects to close */ public static void cleanup(Log log, java.io.Closeable... closeables) { for (java.io.Closeable c : closeables) { if (c != null) { try { c.close(); } catch(IOException e) { if (log != null && log.isDebugEnabled()) { log.debug("Exception in closing " + c, e); } } } } }
Example 11
Source File: TestConfigurationLogger.java From commons-configuration with Apache License 2.0 | 5 votes |
/** * Tests whether debug logging is possible. */ @Test public void testDebug() { final Log log = EasyMock.createMock(Log.class); log.debug(MSG); EasyMock.replay(log); final ConfigurationLogger logger = new ConfigurationLogger(log); logger.debug(MSG); EasyMock.verify(log); }
Example 12
Source File: OracleSpecific.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void unloadDriver(JdbcDriver driver) { super.unloadDriver(driver); if (driver == null) { return; } ClassLoader classLoader = driver.getClassLoader(); if (classLoader != null) { // Oracle driver registers a MBean for each classloader try { Hashtable<String,String> table = new Hashtable<String, String>(); table.put("type", "diagnosability"); String classLoaderId = classLoader.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(classLoader)); table.put("name", classLoaderId); ObjectName name = new ObjectName("com.oracle.jdbc", table); MBeanServer server = ManagementFactory.getPlatformMBeanServer(); if (server.isRegistered(name)) { server.unregisterMBean(name); } } catch (Exception ex) { Log logger = LogFactory.getLog(OracleSpecific.class); if (logger.isDebugEnabled()) { logger.debug("Exception on deregistering the Oracle driver MBean", ex); } } } }
Example 13
Source File: InitializationUtils.java From elasticsearch-hadoop with Apache License 2.0 | 4 votes |
public static void filterNonIngestNodesIfNeeded(Settings settings, Log log) { if (!settings.getNodesIngestOnly()) { return; } RestClient bootstrap = new RestClient(settings); try { String message = "Ingest-only routing specified but no ingest nodes with HTTP-enabled available"; List<NodeInfo> clientNodes = bootstrap.getHttpIngestNodes(); if (clientNodes.isEmpty()) { throw new EsHadoopIllegalArgumentException(message); } if (log.isDebugEnabled()) { log.debug(String.format("Found ingest nodes %s", clientNodes)); } List<String> toRetain = new ArrayList<String>(clientNodes.size()); for (NodeInfo node : clientNodes) { toRetain.add(node.getPublishAddress()); } List<String> ddNodes = SettingsUtils.discoveredOrDeclaredNodes(settings); // remove non-client nodes ddNodes.retainAll(toRetain); if (log.isDebugEnabled()) { log.debug(String.format("Filtered discovered only nodes %s to ingest-only %s", SettingsUtils.discoveredOrDeclaredNodes(settings), ddNodes)); } if (ddNodes.isEmpty()) { if (settings.getNodesDiscovery()) { message += String.format("; looks like the ingest nodes discovered have been removed; is the cluster in a stable state? %s", clientNodes); } else { message += String.format("; node discovery is disabled and none of nodes specified fit the criterion %s", SettingsUtils.discoveredOrDeclaredNodes(settings)); } throw new EsHadoopIllegalArgumentException(message); } SettingsUtils.setDiscoveredNodes(settings, ddNodes); } finally { bootstrap.close(); } }
Example 14
Source File: RestService.java From elasticsearch-hadoop with Apache License 2.0 | 4 votes |
public static PartitionWriter createWriter(Settings settings, long currentSplit, int totalSplits, Log log) { Version.logVersion(); InitializationUtils.validateSettings(settings); InitializationUtils.discoverClusterInfo(settings, log); InitializationUtils.validateSettingsForWriting(settings); InitializationUtils.discoverNodesIfNeeded(settings, log); InitializationUtils.filterNonClientNodesIfNeeded(settings, log); InitializationUtils.filterNonDataNodesIfNeeded(settings, log); InitializationUtils.filterNonIngestNodesIfNeeded(settings, log); List<String> nodes = SettingsUtils.discoveredOrDeclaredNodes(settings); // check invalid splits (applicable when running in non-MR environments) - in this case fall back to Random.. int selectedNode = (currentSplit < 0) ? new Random().nextInt(nodes.size()) : (int)(currentSplit % nodes.size()); // select the appropriate nodes first, to spread the load before-hand SettingsUtils.pinNode(settings, nodes.get(selectedNode)); Resource resource = new Resource(settings, false); log.info(String.format("Writing to [%s]", resource)); // single index vs multi indices IndexExtractor iformat = ObjectUtils.instantiate(settings.getMappingIndexExtractorClassName(), settings); iformat.compile(resource.toString()); // Create the partition writer and its client RestRepository repository; if (iformat.hasPattern()) { // Can't be sure if a multi-index pattern will resolve to indices or aliases // during the job. It's better to trust the user and discover any issues the // hard way at runtime. repository = initMultiIndices(settings, currentSplit, resource, log); } else { // Make sure the resource name is a valid singular index name string candidate if (!StringUtils.isValidSingularIndexName(resource.index())) { throw new EsHadoopIllegalArgumentException("Illegal write index name [" + resource.index() + "]. Write resources must " + "be lowercase singular index names, with no illegal pattern characters except for multi-resource writes."); } // Determine if the configured index is an alias. RestClient bootstrap = new RestClient(settings); GetAliasesRequestBuilder.Response response = null; try { response = new GetAliasesRequestBuilder(bootstrap).aliases(resource.index()).execute(); } catch (EsHadoopInvalidRequest remoteException) { // For now, the get alias call throws if it does not find an alias that matches. Just log and continue. if (log.isDebugEnabled()) { log.debug(String.format("Provided index name [%s] is not an alias. Reason: [%s]", resource.index(), remoteException.getMessage())); } } finally { bootstrap.close(); } // Validate the alias for writing, or pin to a single index shard. if (response != null && response.hasAliases()) { repository = initAliasWrite(response, settings, currentSplit, resource, log); } else { repository = initSingleIndex(settings, currentSplit, resource, log); } } return new PartitionWriter(settings, currentSplit, totalSplits, repository); }
Example 15
Source File: Declaration.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Must be called exactly once, and must be called before any call * to the configure method. */ public void init(Digester digester, PluginManager pm) throws PluginException { Log log = digester.getLogger(); boolean debug = log.isDebugEnabled(); if (debug) { log.debug("init being called!"); } if (initialized) { throw new PluginAssertionFailure("Init called multiple times."); } if ((pluginClass == null) && (pluginClassName != null)) { try { // load the plugin class object pluginClass = digester.getClassLoader().loadClass(pluginClassName); } catch(ClassNotFoundException cnfe) { throw new PluginException( "Unable to load class " + pluginClassName, cnfe); } } if (ruleLoader == null) { // the caller didn't provide a ruleLoader to the constructor, // so get the plugin manager to "discover" one. log.debug("Searching for ruleloader..."); ruleLoader = pm.findLoader(digester, id, pluginClass, properties); } else { log.debug("This declaration has an explicit ruleLoader."); } if (debug) { if (ruleLoader == null) { log.debug( "No ruleLoader found for plugin declaration" + " id [" + id + "]" + ", class [" + pluginClass.getClass().getName() + "]."); } else { log.debug( "RuleLoader of type [" + ruleLoader.getClass().getName() + "] associated with plugin declaration" + " id [" + id + "]" + ", class [" + pluginClass.getClass().getName() + "]."); } } initialized = true; }
Example 16
Source File: ContextLoader.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Initialize Spring's web application context for the given servlet context, * using the application context provided at construction time, or creating a new one * according to the "{@link #CONTEXT_CLASS_PARAM contextClass}" and * "{@link #CONFIG_LOCATION_PARAM contextConfigLocation}" context-params. * @param servletContext current servlet context * @return the new WebApplicationContext * @see #ContextLoader(WebApplicationContext) * @see #CONTEXT_CLASS_PARAM * @see #CONFIG_LOCATION_PARAM */ public WebApplicationContext initWebApplicationContext(ServletContext servletContext) { if (servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null) { throw new IllegalStateException( "Cannot initialize context because there is already a root application context present - " + "check whether you have multiple ContextLoader* definitions in your web.xml!"); } Log logger = LogFactory.getLog(ContextLoader.class); servletContext.log("Initializing Spring root WebApplicationContext"); if (logger.isInfoEnabled()) { logger.info("Root WebApplicationContext: initialization started"); } long startTime = System.currentTimeMillis(); try { // Store context in local instance variable, to guarantee that // it is available on ServletContext shutdown. if (this.context == null) { this.context = createWebApplicationContext(servletContext); } if (this.context instanceof ConfigurableWebApplicationContext) { ConfigurableWebApplicationContext cwac = (ConfigurableWebApplicationContext) this.context; if (!cwac.isActive()) { // The context has not yet been refreshed -> provide services such as // setting the parent context, setting the application context id, etc if (cwac.getParent() == null) { // The context instance was injected without an explicit parent -> // determine parent for root web application context, if any. ApplicationContext parent = loadParentContext(servletContext); cwac.setParent(parent); } configureAndRefreshWebApplicationContext(cwac, servletContext); } } servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.context); ClassLoader ccl = Thread.currentThread().getContextClassLoader(); if (ccl == ContextLoader.class.getClassLoader()) { currentContext = this.context; } else if (ccl != null) { currentContextPerThread.put(ccl, this.context); } if (logger.isDebugEnabled()) { logger.debug("Published root WebApplicationContext as ServletContext attribute with name [" + WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE + "]"); } if (logger.isInfoEnabled()) { long elapsedTime = System.currentTimeMillis() - startTime; logger.info("Root WebApplicationContext: initialization completed in " + elapsedTime + " ms"); } return this.context; } catch (RuntimeException ex) { logger.error("Context initialization failed", ex); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ex); throw ex; } catch (Error err) { logger.error("Context initialization failed", err); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, err); throw err; } }
Example 17
Source File: LogFormatUtils.java From java-technology-stack with MIT License | 3 votes |
/** * Use this to log a message with different levels of detail (or different * messages) at TRACE vs DEBUG log levels. Effectively, a substitute for: * <pre class="code"> * if (logger.isDebugEnabled()) { * String str = logger.isTraceEnabled() ? "..." : "..."; * if (logger.isTraceEnabled()) { * logger.trace(str); * } * else { * logger.debug(str); * } * } * </pre> * @param logger the logger to use to log the message * @param messageFactory function that accepts a boolean set to the value * of {@link Log#isTraceEnabled()} */ public static void traceDebug(Log logger, Function<Boolean, String> messageFactory) { if (logger.isDebugEnabled()) { String logMessage = messageFactory.apply(logger.isTraceEnabled()); if (logger.isTraceEnabled()) { logger.trace(logMessage); } else { logger.debug(logMessage); } } }
Example 18
Source File: LogFormatUtils.java From spring-analysis-note with MIT License | 3 votes |
/** * Use this to log a message with different levels of detail (or different * messages) at TRACE vs DEBUG log levels. Effectively, a substitute for: * <pre class="code"> * if (logger.isDebugEnabled()) { * String str = logger.isTraceEnabled() ? "..." : "..."; * if (logger.isTraceEnabled()) { * logger.trace(str); * } * else { * logger.debug(str); * } * } * </pre> * @param logger the logger to use to log the message * @param messageFactory function that accepts a boolean set to the value * of {@link Log#isTraceEnabled()} */ public static void traceDebug(Log logger, Function<Boolean, String> messageFactory) { if (logger.isDebugEnabled()) { boolean traceEnabled = logger.isTraceEnabled(); String logMessage = messageFactory.apply(traceEnabled); if (traceEnabled) { logger.trace(logMessage); } else { logger.debug(logMessage); } } }
Example 19
Source File: SwiftUtils.java From hadoop with Apache License 2.0 | 2 votes |
/** * Sprintf() to the log iff the log is at debug level. If the log * is not at debug level, the printf operation is skipped, so * no time is spent generating the string. * @param log log to use * @param text text message * @param args args arguments to the print statement */ public static void debug(Log log, String text, Object... args) { if (log.isDebugEnabled()) { log.debug(String.format(text, args)); } }
Example 20
Source File: SwiftUtils.java From sahara-extra with Apache License 2.0 | 2 votes |
/** * Sprintf() to the log iff the log is at debug level. If the log * is not at debug level, the printf operation is skipped, so * no time is spent generating the string. * @param log log to use * @param text text message * @param args args arguments to the print statement */ public static void debug(Log log, String text, Object... args) { if (log.isDebugEnabled()) { log.debug(String.format(text, args)); } }