List of usage examples for org.apache.commons.logging Log isDebugEnabled
boolean isDebugEnabled();
From source file:org.anyframe.iam.admin.common.aspect.LoggingAspect.java
/** * catch and logging through aspect service ( setting : * [src/main/resources/spring/common/context-aspect.xml] ) * /*from w w w .ja v a2 s . c om*/ * @param thisJoinPoint aspect service JoinPoint */ public void beforeLogging(JoinPoint thisJoinPoint) { Object target = thisJoinPoint.getTarget(); while (target instanceof Advised) { try { target = ((Advised) target).getTargetSource().getTarget(); } catch (Exception e) { LogFactory.getLog(this.getClass()).error("Fail to get target object from JointPoint.", e); } } if (target == null) return; String className = target.getClass().getSimpleName(); String opName = (thisJoinPoint.getSignature().getName()); StringBuffer buf = new StringBuffer(); buf.append("\n** Logging Aspect : executed " + opName + "() in " + className + " Class."); Object[] arguments = thisJoinPoint.getArgs(); if (arguments.length > 0) { buf.append("\n************* " + arguments[0].getClass().getName() + " *************\n"); buf.append(arguments[0].toString()); buf.append("\n*********************************************************\n"); } else buf.append("\nNo arguments\n"); Log logger = LogFactory.getLog(target.getClass()); if (logger.isDebugEnabled()) logger.debug(buf.toString()); }
From source file:org.anyframe.oden.admin.aspect.LoggingAspect.java
@Before("execution(* org.anyframe.oden..*Impl.*(..))") public void beforeLogging(JoinPoint thisJoinPoint) { Class<? extends Object> clazz = thisJoinPoint.getTarget().getClass(); String methodName = thisJoinPoint.getSignature().getName(); Object[] arguments = thisJoinPoint.getArgs(); StringBuffer argBuf = new StringBuffer(); StringBuffer argValueBuf = new StringBuffer(); int i = 0;//from ww w. j a v a 2 s .c o m for (Object argument : arguments) { String argClassName = argument.getClass().getSimpleName(); if (i > 0) { argBuf.append(", "); } String arg = argClassName + " arg" + ++i; argBuf.append(arg); argValueBuf.append(".arg" + i + " : " + argument.toString() + "\n"); } if (i == 0) { argValueBuf.append("No arguments\n"); } StringBuffer messageBuf = new StringBuffer(); messageBuf.append("before executing " + methodName + "(" + argBuf.toString() + ") method"); messageBuf.append("\n-------------------------------------------------------------------------------\n"); messageBuf.append(argValueBuf.toString()); messageBuf.append("-------------------------------------------------------------------------------"); Log logger = LogFactory.getLog(clazz); if (logger.isDebugEnabled()) { logger.debug(messageBuf.toString()); } }
From source file:org.anyframe.oden.admin.listener.JasperContextLoaderListener.java
@Override public void contextInitialized(ServletContextEvent event) { Log logger = LogFactory.getLog(JasperContextLoaderListener.class); try {/*from www. ja va2 s .co m*/ Class.forName("org.apache.jasper.compiler.JspRuntimeContext"); } catch (ClassNotFoundException e) { if (logger.isDebugEnabled()) { logger.debug(e.getMessage()); } } }
From source file:org.apache.axiom.om.util.LogOutputStream.java
public LogOutputStream(Log log, int limit) { isDebugEnabled = log.isDebugEnabled(); this.log = log; this.limit = limit; }
From source file:org.apache.camel.processor.PipelineHelper.java
/** * Should we continue processing the exchange? * * @param exchange the next exchange/*from ww w .j a v a 2 s . co m*/ * @param message a message to use when logging that we should not continue processing * @param log a logger * @return <tt>true</tt> to continue processing, <tt>false</tt> to break out, for example if an exception occurred. */ public static boolean continueProcessing(Exchange exchange, String message, Log log) { // check for error if so we should break out boolean exceptionHandled = hasExceptionBeenHandledByErrorHandler(exchange); if (exchange.isFailed() || exchange.isRollbackOnly() || exceptionHandled) { // The Exchange.ERRORHANDLED_HANDLED property is only set if satisfactory handling was done // by the error handler. It's still an exception, the exchange still failed. if (log.isDebugEnabled()) { StringBuilder sb = new StringBuilder(); sb.append("Message exchange has failed " + message + " for exchange: ").append(exchange); if (exchange.isRollbackOnly()) { sb.append(" Marked as rollback only."); } if (exchange.getException() != null) { sb.append(" Exception: ").append(exchange.getException()); } if (exchange.hasOut() && exchange.getOut().isFault()) { sb.append(" Fault: ").append(exchange.getOut()); } if (exceptionHandled) { sb.append(" Handled by the error handler."); } log.debug(sb.toString()); } return false; } // check for stop Object stop = exchange.getProperty(Exchange.ROUTE_STOP); if (stop != null) { boolean doStop = exchange.getContext().getTypeConverter().convertTo(Boolean.class, exchange, stop); if (doStop) { if (log.isDebugEnabled()) { log.debug( "ExchangeId: " + exchange.getExchangeId() + " is marked to stop routing: " + exchange); } return false; } } return true; }
From source file:org.apache.cayenne.dbsync.reverse.dbimport.DefaultDbImportActionTest.java
private DefaultDbImportAction buildDbImportAction(FileProjectSaver projectSaver, MapLoader mapLoader, final DbLoader dbLoader) throws Exception { Log log = mock(Log.class); when(log.isDebugEnabled()).thenReturn(true); when(log.isInfoEnabled()).thenReturn(true); DbAdapter dbAdapter = mock(DbAdapter.class); DbAdapterFactory adapterFactory = mock(DbAdapterFactory.class); when(adapterFactory.createAdapter(any(DataNodeDescriptor.class), any(DataSource.class))) .thenReturn(dbAdapter);/*from w ww . jav a2 s .c om*/ DataSourceFactory dataSourceFactory = mock(DataSourceFactory.class); DataSource mock = mock(DataSource.class); when(dataSourceFactory.getDataSource(any(DataNodeDescriptor.class))).thenReturn(mock); MergerTokenFactoryProvider mergerTokenFactoryProvider = mock(MergerTokenFactoryProvider.class); when(mergerTokenFactoryProvider.get(any(DbAdapter.class))).thenReturn(new DefaultMergerTokenFactory()); return new DefaultDbImportAction(log, projectSaver, dataSourceFactory, adapterFactory, mapLoader, mergerTokenFactoryProvider) { protected DbLoader createDbLoader(DbAdapter adapter, Connection connection, DbImportConfiguration config) { return dbLoader; } }; }
From source file:org.apache.cayenne.tools.dbimport.DbImportActionTest.java
@Test public void testImportWithoutChanges() throws Exception { DbLoader dbLoader = new DbLoader(null, null, null) { @Override/* www. jav a 2 s . c om*/ public void load(DataMap dataMap, DbLoaderConfiguration config) throws SQLException { new DataMapBuilder(dataMap) .with(dbEntity("ARTGROUP").attributes(dbAttr("NAME").typeVarchar(100).mandatory())); } @Override public String[] getDefaultTableTypes() { return null; } }; DbImportConfiguration params = mock(DbImportConfiguration.class); when(params.createLoader(any(DbAdapter.class), any(Connection.class), any(DbLoaderDelegate.class))) .thenReturn(dbLoader); when(params.createDataMap()).thenReturn(new DataMap("testImport")); when(params.getDataMapFile()).thenReturn(FILE_STUB); when(params.createMergeDelegate()).thenReturn(new DefaultModelMergeDelegate()); when(params.getDbLoaderConfig()).thenReturn(new DbLoaderConfiguration()); Log log = mock(Log.class); when(log.isDebugEnabled()).thenReturn(false); when(log.isInfoEnabled()).thenReturn(false); FileProjectSaver projectSaver = mock(FileProjectSaver.class); doNothing().when(projectSaver).save(any(Project.class)); MapLoader mapLoader = mock(MapLoader.class); stub(mapLoader.loadDataMap(any(InputSource.class))).toReturn(new DataMapBuilder() .with(dbEntity("ARTGROUP").attributes(dbAttr("NAME").typeVarchar(100).mandatory())).build()); DbImportAction action = buildDbImportAction(log, projectSaver, mapLoader); action.execute(params); verify(projectSaver, never()).save(any(Project.class)); verify(mapLoader, times(1)).loadDataMap(any(InputSource.class)); }
From source file:org.apache.cayenne.tools.dbimport.DbImportActionTest.java
private DbImportAction buildDbImportAction(FileProjectSaver projectSaver, MapLoader mapLoader) throws Exception { Log log = mock(Log.class); when(log.isDebugEnabled()).thenReturn(true); when(log.isInfoEnabled()).thenReturn(true); return buildDbImportAction(log, projectSaver, mapLoader); }
From source file:org.apache.cocoon.servlet.multipart.MultipartConfigurationHelper.java
/** * Configure this from the settings object. * @param settings/*from w ww.j av a2 s . co m*/ */ public void configure(Settings settings, Log logger) { String value; value = settings.getProperty(KEY_UPLOADS_ENABLE); if (value != null) { setEnableUploads(BooleanUtils.toBoolean(value)); } value = settings.getProperty(KEY_UPLOADS_DIRECTORY); if (value != null) { setUploadDirectory(value); } value = settings.getProperty(KEY_UPLOADS_AUTOSAVE); if (value != null) { setAutosaveUploads(BooleanUtils.toBoolean(value)); } value = settings.getProperty(KEY_UPLOADS_OVERWRITE); if (value != null) { setOverwriteUploads(value); } value = settings.getProperty(KEY_UPLOADS_MAXSIZE); if (value != null) { setMaxUploadSize(Integer.valueOf(value).intValue()); } final String uploadDirParam = getUploadDirectory(); File uploadDir; if (uploadDirParam != null) { uploadDir = new File(uploadDirParam); if (logger.isDebugEnabled()) { logger.debug("Using upload-directory " + uploadDir); } } else { uploadDir = new File(settings.getWorkDirectory(), "upload-dir" + File.separator); if (logger.isDebugEnabled()) { logger.debug("Using default upload-directory " + uploadDir); } } uploadDir.mkdirs(); setUploadDirectory(uploadDir.getAbsolutePath()); }
From source file:org.apache.cocoon.transformation.helpers.PreemptiveLoader.java
/** * Start the preemptive loading// w w w. j a v a 2 s .c o m * @param resolver A source resolver * @param logger A logger */ public void process(SourceResolver resolver, Log logger) { this.alive = true; if (logger.isDebugEnabled()) { logger.debug("PreemptiveLoader: Starting preemptive loading"); } while (this.alive) { while (this.loadList.size() > 0) { Object[] object = (Object[]) this.loadList.get(0); final String uri = (String) object[1]; this.loadList.remove(0); synchronized (object[3]) { ((List) object[3]).remove(uri); } Source source = null; XMLByteStreamCompiler serializer; try { if (logger.isDebugEnabled()) { logger.debug("PreemptiveLoader: Loading " + uri); } source = resolver.resolveURI(uri); serializer = new XMLByteStreamCompiler(); SourceUtil.toSAX(source, serializer); SourceValidity[] validities = new SourceValidity[1]; validities[0] = new ExpiresValidity(((Long) object[2]).longValue() * 1000); // milliseconds! CachedResponse response = new CachedResponse(validities, (byte[]) serializer.getSAXFragment()); ((IncludeCacheStorageProxy) object[0]).put(uri, response); } catch (Exception ignore) { // all exceptions are ignored! } finally { resolver.release(source); } if (logger.isDebugEnabled()) { logger.debug("PreemptiveLoader: Finished loading " + uri); } } synchronized (this.cacheStorageProxyMap) { try { this.cacheStorageProxyMap.wait(); } catch (InterruptedException e) { } } } if (logger.isDebugEnabled()) { logger.debug("PreemptiveLoader: Finished preemptive loading"); } }