List of usage examples for org.apache.commons.logging Log isDebugEnabled
boolean isDebugEnabled();
From source file:org.pentaho.database.service.ServiceLoaderDatabaseDialectProviderTest.java
@Test public void testUsableFilterLog() { Log log = mock(Log.class); when(log.isDebugEnabled()).thenReturn(true); AbstractDatabaseDialect dialect = mock(AbstractDatabaseDialect.class); IDatabaseType type = mock(IDatabaseType.class); IDatabaseDialect iDatabaseDialect = mock(IDatabaseDialect.class); when(iDatabaseDialect.getNativeDriver()).thenReturn(Object.class.getCanonicalName()); when(iDatabaseDialect.getDatabaseType()).thenReturn(type); when(dialect.getDatabaseType()).thenReturn(type); when(dialect.isUsable()).thenReturn(true).thenReturn(false); Predicate<IDatabaseDialect> filter = dialectProvider.usableFilter(log); assertTrue(filter.test(dialect));/*from w w w . ja v a 2s . co m*/ verify(log, times(1)).debug(anyString()); assertFalse(filter.test(dialect)); verify(log, times(3)).debug(anyString()); assertTrue(filter.test(iDatabaseDialect)); verify(log, times(4)).debug(anyString()); iDatabaseDialect = mock(IDatabaseDialect.class); when(iDatabaseDialect.getNativeDriver()).thenReturn("fake.class"); when(iDatabaseDialect.getDatabaseType()).thenReturn(type); assertFalse(filter.test(iDatabaseDialect)); verify(log, times(6)).debug(anyString()); }
From source file:org.pentaho.platform.engine.security.LoggingInterceptor.java
public void before(final Method method, final Object[] args, final Object target) throws Throwable { Log logger = LogFactory.getLog(target.getClass()); if (logger.isDebugEnabled()) { logger.debug(Messages.getInstance().getString("LoggingInterceptor.DEBUG_BEGIN_METHOD")); //$NON-NLS-1$ log(method, args, target);//from ww w . j a va 2 s . c om } }
From source file:org.pentaho.platform.engine.security.LoggingInterceptor.java
public void afterReturning(final Object returnValue, final Method method, final Object[] args, final Object target) throws Throwable { Log logger = LogFactory.getLog(target.getClass()); if (logger.isDebugEnabled()) { logger.debug(Messages.getInstance().getString("LoggingInterceptor.DEBUG_END_METHOD")); //$NON-NLS-1$ log(method, args, target);/*from www . ja v a 2s . c o m*/ logger.debug(Messages.getInstance().getString("LoggingInterceptor.DEBUG_RETURN_VALUE", //$NON-NLS-1$ returnValue.getClass().getName(), toString(returnValue))); } }
From source file:org.pentaho.platform.engine.security.LoggingInterceptor.java
public void afterThrowing(final Method method, final Object[] args, final Object target, final Throwable exception) { Log logger = LogFactory.getLog(target.getClass()); if (logger.isDebugEnabled()) { logger.debug(Messages.getInstance().getString("LoggingInterceptor.DEBUG_EXCEPTION_IN_METHOD")); //$NON-NLS-1$ log(method, args, target);/*from ww w .java 2 s . c o m*/ logger.debug(Messages.getInstance().getString("LoggingInterceptor.DEBUG_EXCEPTION", //$NON-NLS-1$ exception.getClass().getName(), exception.getMessage())); logger.debug(Messages.getInstance().getString("LoggingInterceptor.DEBUG_STACK_TRACE"), exception); //$NON-NLS-1$ } }
From source file:org.pentaho.platform.engine.security.LoggingInterceptor.java
private void log(final Method method, final Object[] args, final Object target) { Log logger = LogFactory.getLog(target.getClass()); if (logger.isDebugEnabled()) { logger.debug(// w w w . j a v a 2s .co m Messages.getInstance().getString("LoggingInterceptor.DEBUG_METHOD_NAME", method.getName())); //$NON-NLS-1$ logger.debug(Messages.getInstance().getString("LoggingInterceptor.DEBUG_TARGET_OBJECT", //$NON-NLS-1$ target.getClass().getName(), toString(target))); logger.debug( Messages.getInstance().getString("LoggingInterceptor.DEBUG_METHOD_ARGS", arrayToString(args))); //$NON-NLS-1$ } }
From source file:org.picocontainer.gems.monitors.CommonsLoggingComponentMonitor.java
/** {@inheritDoc} **/ public <T> void instantiated(final PicoContainer container, final ComponentAdapter<T> componentAdapter, final Constructor<T> constructor, final Object instantiated, final Object[] parameters, final long duration) { Log log = getLog(constructor); if (log.isDebugEnabled()) { log.debug(ComponentMonitorHelper.format(ComponentMonitorHelper.INSTANTIATED, ctorToString(constructor), duration, instantiated.getClass().getName(), parmsToString(parameters))); }/* www . j a va2 s .c o m*/ delegate.instantiated(container, componentAdapter, constructor, instantiated, parameters, duration); }
From source file:org.picocontainer.gems.monitors.CommonsLoggingComponentMonitor.java
/** {@inheritDoc} **/ public Object invoking(final PicoContainer container, final ComponentAdapter<?> componentAdapter, final Member member, final Object instance, final Object[] args) { Log log = getLog(member); if (log.isDebugEnabled()) { log.debug(ComponentMonitorHelper.format(ComponentMonitorHelper.INVOKING, memberToString(member), instance));//from w w w. j ava2 s. c o m } return delegate.invoking(container, componentAdapter, member, instance, args); }
From source file:org.picocontainer.gems.monitors.CommonsLoggingComponentMonitor.java
/** {@inheritDoc} **/ public void invoked(final PicoContainer container, final ComponentAdapter<?> componentAdapter, final Member member, final Object instance, final long duration, final Object[] args, final Object retVal) { Log log = getLog(member); if (log.isDebugEnabled()) { log.debug(ComponentMonitorHelper.format(ComponentMonitorHelper.INVOKED, methodToString(member), instance, duration));//from w w w. j a v a 2 s .c o m } delegate.invoked(container, componentAdapter, member, instance, duration, args, retVal); }
From source file:org.qedeq.base.trace.Trace.java
/** * Is debug log currently enabled?// ww w.j av a 2 s .co m * * @param tracingClass Class we want to know the debug logging status for. * @return Debug log enabled. */ public static boolean isDebugEnabled(final Class tracingClass) { if (traceOn) { final Log log = LogFactory.getFactory().getInstance(tracingClass); return log.isDebugEnabled(); } return false; }
From source file:org.qedeq.base.trace.Trace.java
/** * Trace object./*from w w w . jav a2 s .co m*/ * @param tracingClass Class that wants to make a trace entry. * @param tracingObject Instance that wants to make a trace entry. * @param method Method of that object. * @param object Object to trace. */ public static void trace(final Class tracingClass, final Object tracingObject, final String method, final Object object) { if (traceOn) { final Log log = LogFactory.getFactory().getInstance(tracingClass); if (log.isDebugEnabled()) { log.debug("." + method + " " + object); } } }