List of usage examples for org.apache.commons.logging Log info
void info(Object message);
From source file:org.eclipse.smila.search.utils.param.ParameterSet.java
public static void main(String[] arg) { final Log log = LogFactory.getLog(ParameterSet.class); try {/*from www. j a v a 2s .c o m*/ // DParameterSet einlesen org.w3c.dom.Document d = XMLUtils .parse(new java.io.File("d:/anyfinder/af-engine-sdk/xml/param-testcase.xml"), true); final DParameterSet pset = DParameterSetCodec.decode(d.getDocumentElement()); org.w3c.dom.Document d2 = XMLUtils.getDocument("top"); org.w3c.dom.Element e = d2.getDocumentElement(); org.w3c.dom.Element pelement = DParameterSetCodec.encode(pset, e); XMLUtils.stream(pelement, false, "UTF-8", System.err); // DParameterDefinition einlesen d = XMLUtils.parse(new java.io.File("d:/anyfinder/af-engine-sdk/xml/paramdef-testcase.xml"), true); final DParameterDefinition pdef = DParameterDefinitionCodec.decode(d.getDocumentElement()); d2 = XMLUtils.getDocument("top"); e = d2.getDocumentElement(); pelement = DParameterDefinitionCodec.encode(pdef, e); XMLUtils.stream(pelement, false, "UTF-8", System.err); // ParameterSet erzeugen final ParameterSet ps = new ParameterSet(pset, pdef); final Enumeration en = ps.getParameterNames(); for (; en.hasMoreElements();) { final String pname = (String) en.nextElement(); final String ptype = ps.getParameterType(pname); Object value = ps.getParameter(pname); if (ptype.indexOf("List") >= 0) { String newValue = ""; for (int i = 0; true; i++) { try { newValue += Array.get(value, i); Array.get(value, i + 1); newValue += ", "; } catch (final ArrayIndexOutOfBoundsException iae) { break; } } value = newValue; } if (log.isInfoEnabled()) { log.info(pname + "(" + ptype + "):\t" + value); } } } catch (final Exception e) { if (log.isErrorEnabled()) { log.error(e); } } }
From source file:org.eclipse.smila.utils.config.ConfigUtils.java
/** * Determine folder./* w w w. j a v a 2 s . c o m*/ * * @return the file */ private static File determineFolder() { final Log log = LogFactory.getLog(ConfigUtils.class); File file = null; for (final String path : PRIOTIZED_PATHS) { if (StringUtils.isNotBlank(path)) { file = new File(path); break; } } if (file != null) { if (file.exists()) { if (log.isInfoEnabled()) { log.info("CONFIGURATION_FOLDER = " + file.getAbsolutePath()); } else { System.out.println("CONFIGURATION_FOLDER = " + file.getAbsolutePath()); } } else { if (log.isInfoEnabled()) { log.info("CONFIGURATION_FOLDER ( " + file.getAbsolutePath() + " ) is not found"); } else { System.out.println("CONFIGURATION_FOLDER ( " + file.getAbsolutePath() + " ) is not found"); } file = null; } } else { if (log.isInfoEnabled()) { log.info("No CONFIGURATION_FOLDER is found"); } else { System.out.println("No CONFIGURATION_FOLDER is found"); } } return file; }
From source file:org.eclipse.smila.utils.log.BundleLogHelper.java
/** * Log services./* w w w . j a v a 2s. com*/ */ public static void logBundlesState() { final Log log = LogFactory.getLog(BundleLogHelper.class); String result = ""; for (final Bundle bundle : Platform.getBundle("org.eclipse.core.runtime").getBundleContext().getBundles()) { final String state = DESCRIPTIONS.get(bundle.getState()); result += String.format("\r\n%3d %s %s", bundle.getBundleId(), state, bundle.getSymbolicName()); } if (log.isInfoEnabled()) { log.info(result); } }
From source file:org.eclipse.smila.utils.log.RecordLifecycleLogHelper.java
/** * Logs record state.//from w ww. j a va2 s. c o m * * @param message * message * @param id * record id */ public static void logRecordState(String message, String id) { final Log log = LogFactory.getLog(RECORDS_LOGGER); if (log.isInfoEnabled()) { log.info(message + ", record id=" + id); } }
From source file:org.eclipse.smila.utils.scriptexecution.LogHelper.java
/** * Logs message with specified level.// w w w. j a v a2 s. c o m * * @param log * log * @param message * message * @param logLevel * log level */ private static void log(final Log log, final String message, final LogLevel logLevel) { if (LogLevel.DEBUG.equals(logLevel)) { log.debug(message); } else if (LogLevel.INFO.equals(logLevel)) { log.info(message); } else if (LogLevel.WARN.equals(logLevel)) { log.warn(message); } else if (LogLevel.ERROR.equals(logLevel)) { log.error(message); } else { throw new IllegalArgumentException("Unknown log level [" + logLevel + "]"); } }
From source file:org.eclipse.smila.utils.workspace.WorkspaceHelper.java
/** * read property $bundleName.workspace to determine and ensure a custom workspace for the given bundle. * //from w ww .ja va 2 s . co m * @param bundleName * name of bundle * @param log * error log * * @return working dir, if custom bundle workspace has been specified, else null. */ private static File createCustomBundleWorkspace(final String bundleName, final Log log) { File workingDir = null; final String bundleWorkspaceProperty = bundleName + ".workspace"; String customBundleWorkspace = System.getProperty(bundleWorkspaceProperty); if (customBundleWorkspace == null) { customBundleWorkspace = System.getenv(bundleWorkspaceProperty); } if (!StringUtils.isBlank(customBundleWorkspace)) { if (log.isInfoEnabled()) { log.info("Custom workspace for bundle " + bundleName + " is " + customBundleWorkspace); } final File file = new File(customBundleWorkspace); if (!file.exists()) { file.mkdirs(); } if (file.exists() && file.isDirectory()) { workingDir = file; } else { log.error("Creating custom workspace for bundle " + bundleName + " failed, using fallback locations."); } } return workingDir; }
From source file:org.elasticsearch.hadoop.rest.InitializationUtils.java
public static <T> void saveSchemaIfNeeded(Object conf, ValueWriter<T> schemaWriter, T schema, Log log) { Settings settings = HadoopSettingsManager.loadFrom(conf); if (settings.getIndexAutoCreate()) { RestRepository client = new RestRepository(settings); if (!client.indexExists(false)) { if (schemaWriter == null) { log.warn(String.format( "No mapping found [%s] and no schema found; letting Elasticsearch perform auto-mapping...", settings.getResourceWrite())); } else { log.info(String.format("No mapping found [%s], creating one based on given schema", settings.getResourceWrite())); ContentBuilder builder = ContentBuilder.generate(schemaWriter).value(schema).flush(); BytesArray content = ((FastByteArrayOutputStream) builder.content()).bytes(); builder.close();/*from w ww. j a v a 2 s .c o m*/ client.putMapping(content); if (log.isDebugEnabled()) { log.debug(String.format("Creating ES mapping [%s] from schema [%s]", content.toString(), schema)); } } } client.close(); } }
From source file:org.elasticsearch.hadoop.util.DateUtils.java
public static Calendar parseDate(String value) { if (!printed) { printed = true;/* w w w . j ava 2 s . c o m*/ Log log = LogFactory.getLog(DateUtils.class); if (jodaTimeAvailable && JodaTime.INITIALIZED) { log.info("Joda library available in the classpath; using it for date/time handling..."); } else { // be silent otherwise } } return (jodaTimeAvailable && JodaTime.INITIALIZED) ? JodaTime.parseDate(value) : Jdk6.parseDate(value); }
From source file:org.eurekastreams.commons.search.analysis.SynonymMapFactory.java
/** * Initialize the synonym map./* w ww .j a v a 2 s . c om*/ * * @param thesaurusInputStream * InputStream of the WordNet synonyms file * @return true */ public static boolean inform(final InputStream thesaurusInputStream) { if (synonyms == null) { synchronized (SynonymMapFactory.class) { Log initLog = LogFactory.getLog(SynonymMapFactory.class); initLog.debug("Initializing SynonymMap."); try { // NOTE: the synonym stream is closed inside SynonymMap synonyms = new SynonymMap(thesaurusInputStream); } catch (Exception e) { throw new RuntimeException(e); } initLog.info("Testing SynonymMap."); if (initLog.isInfoEnabled()) { initLog.info("Synonyms for 'success': " + Arrays.toString(synonyms.getSynonyms("success"))); } initLog.info("SynonymMap initializing complete."); } } return true; }
From source file:org.eurekastreams.server.aop.PerformanceTimer.java
/** * Method for logging timing data.//from w w w. j av a 2s . c om * * @param call * {@link ProceedingJoinPoint} * @return result of wrapped method. * @throws Throwable * on error. */ public Object profile(final ProceedingJoinPoint call) throws Throwable { StopWatch clock = null; // get the perf log for target object. Log log = LogFactory.getLog("perf.timer." + call.getTarget().getClass().getCanonicalName()); try { if (log.isInfoEnabled()) { clock = new StopWatch(); clock.start(call.toShortString()); } return call.proceed(); } finally { if (log.isInfoEnabled() && clock != null) { clock.stop(); Object[] args = call.getArgs(); StringBuffer params = new StringBuffer(); for (Object obj : args) { params.append("Param: " + ((obj == null) ? "null" : obj.toString()) + "\n\t"); } log.info(clock.getTotalTimeMillis() + " (ms) - " + call.getTarget().getClass().getSimpleName() + "." + call.getSignature().toShortString() + "\n\t" + params.toString()); } } }