List of usage examples for org.apache.commons.logging Log isDebugEnabled
boolean isDebugEnabled();
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the given message to the log at the debug level. If the log level is not enabled, this method does * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned. * * @param log the log where the messages will go * @param basename the base name of the resource bundle * @param locale the locale to determine what bundle to use * @param key the resource bundle key name * @param varargs arguments to help fill in the resource bundle message * * @return if the message was logged, a non-<code>null</code> Msg object is returned *//*from ww w .ja v a2 s . c o m*/ public static Msg debug(Log log, BundleBaseName basename, Locale locale, String key, Object... varargs) { if (log.isDebugEnabled()) { Msg msg = Msg.createMsg(basename, locale, key, varargs); log.debug((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg); return msg; } return null; }
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the given message to the log at the debug level. If the log level is not enabled, this method does * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned. * * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p> * * @param log the log where the messages will go * @param throwable the throwable associated with the log message * @param basename the base name of the resource bundle * @param key the resource bundle key name * @param varargs arguments to help fill in the resource bundle message * * @return if the message was logged, a non-<code>null</code> Msg object is returned *///from w w w .jav a 2 s. com public static Msg debug(Log log, Throwable throwable, BundleBaseName basename, String key, Object... varargs) { if (log.isDebugEnabled()) { Msg msg = Msg.createMsg(basename, key, varargs); logDebugWithThrowable(log, key, msg, throwable); return msg; } return null; }
From source file:gaderian.test.services.TestAssemblyInstruction.java
private void trainDebug(AssemblyParameters fp, Log log, String string) { expect(fp.getLog()).andReturn(log);/* w w w .j a va 2 s . co m*/ expect(log.isDebugEnabled()).andReturn(true); log.debug(string); }
From source file:com.tecapro.inventory.common.util.LogUtil.java
/** * //from ww w . j a va 2 s. com * Debug log output * * @param log * @param clazz * @param method * @param time */ public void debugLog(Log log, String clazz, String method, InfoValue info, String message) { if (log.isDebugEnabled()) { log.debug(returnLogString(clazz, method, info, LogPrefix.OTHER, message)); } }
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the given message to the log at the debug level. If the log level is not enabled, this method does * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned. * * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p> * * @param log the log where the messages will go * @param throwable the throwable associated with the log message * @param basename the base name of the resource bundle * @param locale the locale to determine what bundle to use * @param key the resource bundle key name * @param varargs arguments to help fill in the resource bundle message * * @return if the message was logged, a non-<code>null</code> Msg object is returned *//* www. j a v a 2s . com*/ public static Msg debug(Log log, Throwable throwable, BundleBaseName basename, Locale locale, String key, Object... varargs) { if (log.isDebugEnabled()) { Msg msg = Msg.createMsg(basename, locale, key, varargs); logDebugWithThrowable(log, key, msg, throwable); return msg; } return null; }
From source file:com.teletalk.jserver.util.aop.MethodInvocationDebugLogger.java
/** */// w w w .j a v a 2s.c o m public Object invoke(final MethodInvocation methodInvocation) throws Throwable { Method method = methodInvocation.getMethod(); String paramLogString = null; long executionStartTime = System.currentTimeMillis(); Log logger = this.logger; String methodName; if (logger == null) { logger = LogFactory.getLog(method.getDeclaringClass()); methodName = method.getName(); } else methodName = method.getDeclaringClass().getName() + "." + method.getName(); if (logger.isDebugEnabled()) { paramLogString = ""; Object[] arguments = methodInvocation.getArguments(); if (arguments != null) { for (int i = 0; i < arguments.length; i++) { paramLogString += StringUtils.limitStringLength(StringUtils.toString(arguments[i]), this.maxParameterStringRepresentationLength); if (i < (arguments.length - 1)) paramLogString += ", "; } } logger.debug("Executing " + methodName + "(" + paramLogString + ")."); } Object returnValue = methodInvocation.proceed(); if (logger.isDebugEnabled()) { if ((method.getReturnType() == null) || method.getReturnType().equals(Void.TYPE)) { logger.debug("Done executing " + methodName + "(" + paramLogString + ") after " + (System.currentTimeMillis() - executionStartTime) + "ms."); } else { logger.debug("Done executing " + methodName + "(" + paramLogString + ") after " + (System.currentTimeMillis() - executionStartTime) + "ms" + " - return value: " + StringUtils.limitStringLength(StringUtils.toString(returnValue), this.maxReturnValueStringRepresentationLength) + "."); } } return returnValue; }
From source file:net.sf.nmedit.nordmodular.Installer.java
private void loadSessionFromProperties(TempDir tmpDir, Properties props) { String PCountString = props.getProperty(SESSION_PATCHCOUNT); if (PCountString == null) return;/*from w w w . ja v a 2s. com*/ int patchcount; try { patchcount = Integer.parseInt(PCountString); } catch (NumberFormatException e) { Log log = LogFactory.getLog(getClass()); if (log.isDebugEnabled()) { log.debug("exception while loading session file", e); } return; } for (int i = 0; i < patchcount; i++) { File sourceFile = null; String keySourceFile = getSourceFileKey(i); String sourceFileString = props.getProperty(keySourceFile); if (sourceFileString != null) sourceFile = new File(sourceFileString); File tmpFile = getPatchTmpFile(tmpDir, i); String title = props.getProperty(getTitleKey(i)); NMPatch patch = tryOpenSessionPatch(tmpFile, sourceFile, title); } }
From source file:net.sf.nmedit.nordmodular.Installer.java
private void loadLastSession() { TempDir tmpDir = TempDir.forObject(this); File sessionFile = getSessionFile(tmpDir); if (!sessionFile.exists()) return;//from w w w.j a v a2 s.c o m Properties props = new Properties(); InputStream in; try { in = new BufferedInputStream(new FileInputStream(sessionFile)); try { props.load(in); } finally { in.close(); } } catch (Exception e) { Log log = LogFactory.getLog(getClass()); if (log.isDebugEnabled()) { log.debug("exception while loading session file", e); } e.printStackTrace(); // ignore // delete corrupt session file sessionFile.delete(); return; } loadSessionFromProperties(tmpDir, props); }
From source file:eu.qualityontime.commons.MethodUtils.java
/** * Gets the class for the primitive type corresponding to the primitive * wrapper class given. For example, an instance of * <code>Boolean.class</code> returns a <code>boolean.class</code>. * /* ww w.ja va2 s. c o m*/ * @param wrapperType * the * @return the primitive type class corresponding to the given wrapper * class, null if no match is found */ public static Class<?> getPrimitiveType(final Class<?> wrapperType) { // does anyone know a better strategy than comparing names? if (Boolean.class.equals(wrapperType)) { return boolean.class; } else if (Float.class.equals(wrapperType)) { return float.class; } else if (Long.class.equals(wrapperType)) { return long.class; } else if (Integer.class.equals(wrapperType)) { return int.class; } else if (Short.class.equals(wrapperType)) { return short.class; } else if (Byte.class.equals(wrapperType)) { return byte.class; } else if (Double.class.equals(wrapperType)) { return double.class; } else if (Character.class.equals(wrapperType)) { return char.class; } else { final Log log = LogFactory.getLog(MethodUtils.class); if (log.isDebugEnabled()) { log.debug("Not a known primitive wrapper class: " + wrapperType); } return null; } }
From source file:net.sf.nmedit.nordmodular.Installer.java
private void saveCurrentSession() { DefaultDocumentManager dm = Nomad.sharedInstance().getDocumentManager(); List<NMPatch> patches = new ArrayList<NMPatch>(); for (Document doc : dm.getDocuments()) { if (doc instanceof PatchDocument) { patches.add(((PatchDocument) doc).getPatch()); }/*from www .j a va 2 s . c o m*/ } TempDir tmpDir = TempDir.forObject(this); Properties props = new Properties(); int pcount = 0; for (NMPatch patch : patches) { File saveAs = getPatchTmpFile(tmpDir, pcount); try { OutputStream out = new BufferedOutputStream(new FileOutputStream(saveAs)); PatchFileWriter pfw = new PatchFileWriter(out); PatchExporter export = new PatchExporter(); export.export(patch, pfw); out.flush(); out.close(); } catch (Exception e) { Log log = LogFactory.getLog(getClass()); if (log.isDebugEnabled()) { log.debug("exception while storing session file", e); } e.printStackTrace(); continue; } // tmp file written File sourceFile = patch.getFile(); if (sourceFile != null) props.put(getSourceFileKey(pcount), sourceFile.getAbsolutePath()); else { // source file unknown, since patch file contains no title we have to remember it String name = patch.getName(); if (name != null) props.put(getTitleKey(pcount), name); } pcount++; } props.put(SESSION_PATCHCOUNT, String.valueOf(pcount)); File sessionFile = getSessionFile(tmpDir); try { OutputStream out = new BufferedOutputStream(new FileOutputStream(sessionFile)); props.store(out, "generated file - do not edit manually"); out.close(); } catch (Exception e) { Log log = LogFactory.getLog(getClass()); if (log.isDebugEnabled()) { log.debug("exception while storing session file", e); } e.printStackTrace(); // ignore } }