List of usage examples for org.apache.commons.logging Log debug
void debug(Object message);
From source file:org.jboss.netty.logging.CommonsLoggerTest.java
@Test public void testDebug() { org.apache.commons.logging.Log mock = createStrictMock(org.apache.commons.logging.Log.class); mock.debug("a"); replay(mock);// w w w. j av a2 s. co m InternalLogger logger = new CommonsLogger(mock, "foo"); logger.debug("a"); verify(mock); }
From source file:org.jbpm.graph.def.ProcessDefinition.java
private static List loadModuleClasses(String resource) { Properties properties = ClassLoaderUtil.getProperties(resource); List moduleClasses = new ArrayList(); Log log = LogFactory.getLog(ProcessDefinition.class); boolean debug = log.isDebugEnabled(); for (Iterator iter = properties.keySet().iterator(); iter.hasNext();) { String moduleClassName = (String) iter.next(); try {// ww w. j ava 2 s . co m Class moduleClass = ClassLoaderUtil.classForName(moduleClassName); moduleClasses.add(moduleClass); if (debug) log.debug("loaded module " + moduleClassName); } catch (ClassNotFoundException e) { if (debug) log.debug("module class not found: " + moduleClassName, e); } } return moduleClasses; }
From source file:org.jbpm.jpdl.par.ProcessArchive.java
private static List createParsers(String resource) { // read parsers resource InputStream resourceStream = ClassLoaderUtil.getStream(resource); Element parsersElement = XmlUtil.parseXmlInputStream(resourceStream).getDocumentElement(); List parsers = new ArrayList(); Log log = LogFactory.getLog(ProcessArchive.class); boolean debug = log.isDebugEnabled(); for (Iterator iter = XmlUtil.elementIterator(parsersElement, "parser"); iter.hasNext();) { Element parserElement = (Element) iter.next(); String parserClassName = parserElement.getAttribute("class"); // load parser class try {/* w ww . j ava 2s .c o m*/ Class parserClass = ClassLoaderUtil.classForName(parserClassName); // instantiate parser try { ProcessArchiveParser parser = (ProcessArchiveParser) parserClass.newInstance(); if (parser instanceof ConfigurableParser) { ((ConfigurableParser) parser).configure(parserElement); } parsers.add(parser); if (debug) log.debug("loaded " + parserClass); } catch (InstantiationException e) { if (debug) log.debug("failed to instantiate " + parserClass, e); } catch (IllegalAccessException e) { if (debug) log.debug(ProcessArchive.class + " has no access to " + parserClass, e); } } catch (ClassNotFoundException e) { if (debug) log.debug("parser not found: " + parserClassName, e); } } return parsers; }
From source file:org.jkcsoft.java.util.OsHelper.java
public static boolean isExecutable(File file, Log log) throws Exception { boolean is = true; if (isLinux()) { // e.g., /usr/bin/test -x /home/coles/build/build-tsess.sh && echo yes || echo no try {/*from w w w . j a v a 2 s. co m*/ Runtime rt = Runtime.getRuntime(); String stTest = "/usr/bin/test -x " + file.getAbsolutePath() + " && echo yes || echo no"; log.debug("Command=" + stTest); Process p = rt.exec(stTest); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); String stLine = null; // read any errors from the attempted command log.info("Here is the standard error of the command (if any):"); while ((stLine = stdError.readLine()) != null) { log.warn(stLine); } // read the output from the command StringBuilder sbResponse = new StringBuilder(); while ((stLine = stdInput.readLine()) != null) { sbResponse.append(stLine); } is = "yes".equalsIgnoreCase(sbResponse.toString()); } catch (IOException e) { log.error("In isExecutable()", e); throw e; } } else { log.info("Not Linux -- assume executable"); } return is; }
From source file:org.kuali.kra.logging.BufferedLogger.java
/** * Wraps {@link Log#debug(String)}// w w w . j a v a2 s.c o m * * @param pattern to format against * @param objs an array of objects used as parameters to the <code>pattern</code> */ public static final void debug(Object... objs) { Log log = getLogger(); if (log.isDebugEnabled()) { log.debug(getMessage(objs)); } }
From source file:org.lilyproject.runtime.classloading.ClassLoaderBuilder.java
public static synchronized ClassLoader build(List<ClasspathEntry> classpathEntries, ClassLoader parentClassLoader, ArtifactRepository repository) throws ArtifactNotFoundException, MalformedURLException { if (classLoaderCacheEnabled) { ///*from ww w .j a v a2 s . c o m*/ // About the ClassLoader cache: // The ClassLoader cache was introduced to handle leaks in the 'Perm Gen' and 'Code Cache' // JVM memory spaces when repeatedly restarting Lily Runtime within the same JVM. In such cases, // on each restart Lily Runtime would construct new class loaders, hence the classes loaded through // them would be new and would stress those JVM memory spaces. // // The solution here is good enough for what it is intended to do (restarting the same Lily Runtime // app, unchanged, many times). There is no cache cleaning and the cache key calculation // is not perfect, so if you would enable the cache when starting a wide variety of Lily Runtime // apps within one VM or for reloading changed Lily Runtime apps, it could be problematic. // StringBuilder cacheKeyBuilder = new StringBuilder(2000); for (ClasspathEntry entry : classpathEntries) { cacheKeyBuilder.append(entry.getArtifactRef()).append("\u2603" /* unicode snowman as separator */); } // Add some identification of the parent class loader if (parentClassLoader instanceof URLClassLoader) { for (URL url : ((URLClassLoader) parentClassLoader).getURLs()) { cacheKeyBuilder.append(url.toString()); } } String cacheKey = cacheKeyBuilder.toString(); ClassLoader classLoader = classLoaderCache.get(cacheKey); if (classLoader == null) { Log log = LogFactory.getLog(ClassLoaderBuilder.class); log.debug("Creating and caching a new classloader"); classLoader = create(classpathEntries, parentClassLoader, repository); classLoaderCache.put(cacheKey, classLoader); } else if (classLoader.getParent() != parentClassLoader) { Log log = LogFactory.getLog(ClassLoaderBuilder.class); log.error("Lily Runtime ClassLoader cache: parentClassLoader of cache ClassLoader is different" + " from the specified one. Returning the cached one anyway."); } return classLoader; } else { return create(classpathEntries, parentClassLoader, repository); } }
From source file:org.lilyproject.util.hbase.LocalHTable.java
public HTablePool getHTablePool(Configuration conf) { HTablePool pool;/*from w w w . ja v a 2 s . com*/ synchronized (HTABLE_POOLS) { pool = HTABLE_POOLS.get(conf); if (pool == null) { pool = new HTablePool(conf, 20, new HTableFactory()); HTABLE_POOLS.put(conf, pool); Log log = LogFactory.getLog(LocalHTable.class); if (log.isDebugEnabled()) { log.debug("Created a new HTablePool instance for conf " + System.identityHashCode(conf)); } } } return pool; }
From source file:org.mmadsen.sim.transmissionlab.population.SingleTraitPopulationFactory.java
public IAgentSet generatePopulation() { Log log = model.getLog(); String populationType = null; Integer numAgents = 0;/* ww w. j a v a 2 s .c o m*/ try { populationType = (String) this.model.getSimpleModelPropertyByName("initialTraitStructure"); numAgents = (Integer) this.model.getSimpleModelPropertyByName("numAgents"); } catch (RepastException ex) { System.out.println("FATAL EXCEPTION: " + ex.getMessage()); System.exit(1); } if (populationType == null) { log.info("No initial trait structure chosen, defaulting to SequentialTrait"); populationType = "SequentialTrait"; } if (populationType.equalsIgnoreCase("SequentialTrait")) { log.debug("Constructing UnstructuredSequentialTrait population"); return new UnstructuredSequentialTraits(numAgents, log); } else if (populationType.equalsIgnoreCase("GaussianTrait")) { log.debug("Constructing UnstructuredGaussianTrait population"); return new UnstructuredGaussianInitialTraits(numAgents, log); } // this should never happen but the method has to return SOMETHING in the code path return null; }
From source file:org.nebulaframework.util.profiling.ProfilingAspect.java
/** * Advice of Profiling Aspect. Measures and logs the exection * time of advised method./* ww w . java 2s .c o m*/ * * @param pjp {ProceedingJoinPoint} * @return Object result * @throws Throwable if exception occurs */ @Around("profilingPointcut()") public Object profile(ProceedingJoinPoint pjp) throws Throwable { StopWatch sw = new StopWatch(); Log localLog = null; try { // Get Log localLog = LogFactory.getLog(pjp.getTarget().getClass()); // Start StopWatch sw.start(); // Proceed Invocation return pjp.proceed(); } finally { // Stop StopWatch sw.stop(); if (localLog == null) { // If local Log not found, use ProfilingAspect's Log localLog = log; } //Log Stats localLog.debug("[Profiling] " + pjp.getTarget().getClass().getName() + "->" + pjp.getSignature().getName() + "() | " + sw.getLastTaskTimeMillis() + " ms"); } }
From source file:org.nuxeo.ecm.automation.core.operations.LogOperation.java
@OperationMethod public void run() { if (category == null) { category = "org.nuxeo.ecm.automation.logger"; }//w w w. ja va 2s. c om Log log = LogFactory.getLog(category); if ("debug".equals(level)) { log.debug(message); return; } if ("warn".equals(level)) { log.warn(message); return; } if ("error".equals(level)) { log.error(message); return; } // in any other case, use info log level log.info(message); }