List of usage examples for org.apache.commons.logging Log info
void info(Object message);
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the given message to the log at the info 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 *//* w w w. ja v a2 s.c o m*/ public static Msg info(Log log, BundleBaseName basename, Locale locale, String key, Object... varargs) { if (log.isInfoEnabled()) { Msg msg = Msg.createMsg(basename, locale, key, varargs); log.info((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg); return msg; } return null; }
From source file:com.chinamobile.bcbsp.comm.io.util.MemoryAllocator.java
/** Show the information of memory used. */ public void PrintMemoryInfo(Log LOG) { MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); MemoryUsage memoryUsage = memoryMXBean.getHeapMemoryUsage(); long usedNow = memoryUsage.getUsed(); long committedNow = memoryUsage.getCommitted(); long maxHeapSizeNow = memoryUsage.getMax(); long remainNow = maxHeapSize - used; LOG.info("Memory Usage **********************************************"); LOG.info("Memory Max ****************** " + maxHeapSizeNow); LOG.info("Memory Commit **************** " + committedNow + "-----Percents: " + committedNow * 1.0f / maxHeapSizeNow); LOG.info("Memory Used ****************** " + usedNow + "-----Percents: " + usedNow * 1.0f / maxHeapSizeNow); LOG.info("Memory Remain **************** " + remainNow + "-----Percents: " + remainNow * 1.0f / maxHeapSizeNow); }
From source file:net.java.dev.weblets.impl.WebletContainerImpl.java
public WebletContainerImpl(ServletContext servletContext, String webletContextPath, Format webletURLFormat, Pattern webletURLPattern, boolean multipleConfigs) throws WebletException { _servletContext = servletContext;/* w ww . j a v a 2 s. c o m*/ _webletURLFormat = webletURLFormat; _webletURLPattern = webletURLPattern; _webletContextPath = webletContextPath; checkWebletsContextPath(); try { Set configs = new HashSet(); // Enumeration e = getConfigEnumeration("weblets-config.xml"); /*lets find the root configs first*/ Set urls = new HashSet(); // urls.add(element); if (multipleConfigs) { ConfigurationUtils.getValidConfigFiles(Const.REL_META_INF, Const.WEBLETS_CONFIG_XML, configs); try { ConfigurationUtils.getValidConfigFiles(Const.REL_META_INF, Const.MANIFEST_MF, configs); } catch (NullPointerException ex) { Log log = LogFactory.getLog(this.getClass()); log.info( "MANIFEST.MF search failed for configurations, if you use Websphere, then you can safely ignore this please use a weblets-config.xml as entry point for your weblets configuration, please !"); } Iterator configNameIterator = configs.iterator(); // Defensive: Glassfish.v2.b25 produces duplicates in Enumeration // returned by loader.getResources() while (configNameIterator.hasNext()) { Enumeration theUrlEnum = ConfigurationUtils.getConfigEnumeration(Const.REL_META_INF, (String) configNameIterator.next()); while (theUrlEnum.hasMoreElements()) { URL resource = (URL) theUrlEnum.nextElement(); urls.add(resource); } } } else { Enumeration theUrlEnum = ConfigurationUtils.getConfigEnumeration(Const.REL_META_INF, Const.WEBLETS_CONFIG_XML); while (theUrlEnum.hasMoreElements()) { URL resource = (URL) theUrlEnum.nextElement(); urls.add(resource); } } Iterator urlIterator = urls.iterator(); while (urlIterator.hasNext()) { URL resource = (URL) urlIterator.next(); registerConfig(resource); } WebletContainer.setInstance(this); } catch (IOException e) { throw new WebletException(e); } }
From source file:com.acciente.induction.dispatcher.model.ModelPool.java
public ModelPool(Config.ModelDefs oModelDefs, ModelFactory oModelFactory) throws MethodNotFoundException, InvocationTargetException, ClassNotFoundException, ConstructorNotFoundException, ParameterProviderException, IllegalAccessException, InstantiationException { _oModelDefs = oModelDefs;// w ww. j a va2s. c o m _oModelFactory = oModelFactory; _oAppScopeModelMap = new Hashtable(); // we use a hashtable instead of a HashMap for safe concurrent access Log oLog = LogFactory.getLog(ModelPool.class); // initialize the models set to initialize on startup for (Iterator oIter = oModelDefs.getModelDefList().iterator(); oIter.hasNext();) { Config.ModelDefs.ModelDef oModelDef = (Config.ModelDefs.ModelDef) oIter.next(); if (oModelDef.isApplicationScope() && oModelDef.isInitOnStartUp()) { oLog.info("model-pool: initializing model: " + oModelDef.getModelClassName()); getApplicationScopeModel(oModelDef, null); } } }
From source file:com.tecapro.inventory.common.util.LogUtil.java
/** * /*ww w .ja v a 2 s. com*/ * Start log output * * @param log * @param clazz * @param method * @return */ public long startLog(Log log, String clazz, String method, InfoValue info) { long time = System.nanoTime(); long totalMemory = Runtime.getRuntime().totalMemory(); long freeMemory = Runtime.getRuntime().freeMemory(); log.info(returnLogString(clazz, method, info, LogPrefix.START, new StringBuffer().append(totalMemory - freeMemory).append(",").append(totalMemory).toString())); Integer level = LOG_LEVEL.get(Thread.currentThread()); if (level == null) { level = Integer.valueOf(1); } else { level += 1; } LOG_LEVEL.put(Thread.currentThread(), level); return time; }
From source file:io.smartspaces.workbench.project.test.IsolatedJavaTestRunner.java
/** * Run all JUnit tests./*from w w w . j av a2 s. c o m*/ * * @param testClasses * the names of the detected JUnit classes * @param log * logger for the test run * * @return {@code true} if all tests succeeded */ private boolean runJunitTests(List<Class<?>> testClasses, Log log) { JUnitCore junit = new JUnitCore(); junit.addListener(new RunListener() { @Override public void testFailure(Failure failure) throws Exception { reportFailure(failure, log); } @Override public void testAssumptionFailure(Failure failure) { reportFailure(failure, log); } }); log.info("Starting JUnit tests"); boolean allSucceeded = true; Collections.sort(testClasses, CLASS_COMPARATOR); for (Class<?> testClass : testClasses) { try { Result result = junit.run(testClass); log.info(String.format("Ran %2d tests in %4dms: %d failed, %d ignored. (%s)", result.getRunCount(), result.getRunTime(), result.getFailureCount(), result.getIgnoreCount(), testClass.getName())); allSucceeded &= result.wasSuccessful(); } catch (Exception e) { log.error(String.format("Error while running test class %s", testClass.getName()), e); } } log.info("JUnit tests complete"); return allSucceeded; }
From source file:Navigation.Vertex.java
public static ArrayList<Point2D.Double> getMyDijkstra(Map<Point2D.Double, List<Point2D.Double>> adjacencyMatrix, Point2D.Double start, Point2D.Double end, Log log) { // log.info("start: " + start.toString()); // end = new Point2D.Double(1.3595287799835205, 2.2231287956237793); // log.info("END: " + end.toString()); Iterator<Entry<Point2D.Double, List<Point2D.Double>>> it = adjacencyMatrix.entrySet().iterator(); List<Vertex> vertices = new ArrayList<Vertex>(); while (it.hasNext()) { Map.Entry<Point2D.Double, List<Point2D.Double>> pairs = it.next(); Point2D.Double point1 = pairs.getKey(); vertices.add(new Vertex(point1)); // log.info("added new vertex for " + point1.toString()); }// w ww. j ava2 s . c o m Iterator<Entry<Point2D.Double, List<Point2D.Double>>> pit = adjacencyMatrix.entrySet().iterator(); while (pit.hasNext()) { Map.Entry<Point2D.Double, List<Point2D.Double>> pairs = pit.next(); Point2D.Double point1 = pairs.getKey(); Vertex v1 = findVertex(vertices, point1); for (Point2D.Double point2 : pairs.getValue()) { double cost = Math.sqrt( Math.pow(Math.abs(point1.x - point2.x), 2) + Math.pow(Math.abs(point1.y - point2.y), 2)); Vertex v2 = findVertex(vertices, point2); v1.adjacencies.add(new Edge(v2, cost)); v2.adjacencies.add(new Edge(v1, cost)); } } log.info("looking for start vertex " + start); DijkstraGood.computePaths(findVertex(vertices, start)); // for (Vertex v : vertices) { // List<Edge> edges = v.adjacencies; // String s = v + " {"; // for (Edge e : edges) { // s += e.target.toString() + ", "; // } // log.info(s); // log.info("Distance to " + v + ": " + v.minDistance); // List<Vertex> path = DijkstraGood.getShortestPathTo(v); // log.info("Path: " + path); // } Vertex endV = findVertex(vertices, end); List<Vertex> path = DijkstraGood.getShortestPathTo(endV); ArrayList<Point2D.Double> fin = new ArrayList<Point2D.Double>(); for (Vertex v : path) { if (v.minDistance == Double.POSITIVE_INFINITY) { return null; } fin.add(v.myPoint); log.info("FINAL PATH TO " + v.myPoint); } return fin; }
From source file:interactivespaces.workbench.project.test.IsolatedJavaTestRunner.java
/** * Run all JUnit tests./* w w w .ja va 2 s. c om*/ * * @param classLoader * the classloader for loading test classes * @param testClassNames * the names of the detected JUnit classes * @param log * logger for the test run * * @return {@code true} if all tests succeeded */ private boolean runJunitTests(URLClassLoader classLoader, List<String> testClassNames, final Log log) { JUnitCore junit = new JUnitCore(); junit.addListener(new RunListener() { @Override public void testFailure(Failure failure) throws Exception { reportFailure(failure, log); } @Override public void testAssumptionFailure(Failure failure) { reportFailure(failure, log); } }); log.info("Starting JUnit tests"); boolean allSucceeded = true; for (String testClassName : testClassNames) { try { Class<?> testClass = classLoader.loadClass(testClassName); Result result = junit.run(testClass); log.info(String.format("Ran %2d tests in %4dms: %d failed, %d ignored. (%s)", result.getRunCount(), result.getRunTime(), result.getFailureCount(), result.getIgnoreCount(), testClassName)); allSucceeded &= result.wasSuccessful(); } catch (Exception e) { log.error(String.format("Error while running test class %s", testClassName), e); } } log.info("JUnit tests complete"); return allSucceeded; }
From source file:interactivespaces.activity.component.route.ros.RosMessageRouterActivityComponent.java
@Override public void shutdownComponent() { running = false;/* w ww.j a va2 s . com*/ Log log = getComponentContext().getActivity().getLog(); log.info("Shutting down ROS message router activity component"); long timeStart = System.currentTimeMillis(); clearAllChannelTopics(); if (log.isInfoEnabled()) { log.info(String.format("ROS message router activity component shut down in %d msecs", System.currentTimeMillis() - timeStart)); } }
From source file:dk.statsbiblioteket.util.Logs.java
/** * Log the message and the elements to the log at the specified level. * Elements are converted to Strings and appended to the message. Arrays, * Lists and similar in the elements are expanded to a certain degree of * detail.//from w w w. j a va 2 s . c o m * * Sample input/output: * <code>log(myLog, Level.TRACE, false, "Started test", null, * 5, new String[]{"flim", "flam"});</code> * expands to * <code>log.trace("Started test (5, (flim, flam))");</code> * * @param log the log to log to. * @param level the level to log to (e.g. TRACE, DEBUG, INFO...). * @param verbose if true, the elements are expanded more than for false. * @param error the cause of this logging. If null, no cause is logged. * @param message the message for the log. * @param elements the elements to log. */ public static void log(Log log, Level level, String message, Throwable error, boolean verbose, Object... elements) { int maxLength = verbose ? VERBOSE_MAXLENGTH : DEFAULT_MAXLENGTH; int maxDepth = verbose ? VERBOSE_MAXDEPTH : DEFAULT_MAXDEPTH; String expanded = message; if (elements != null && elements.length > 0) { expanded += expand(elements, maxLength, maxDepth); } switch (level) { case TRACE: if (!log.isTraceEnabled()) { return; } if (error == null) { log.trace(expanded); } else { log.trace(expanded, error); } break; case DEBUG: if (!log.isDebugEnabled()) { return; } if (error == null) { log.debug(expanded); } else { log.debug(expanded, error); } break; case INFO: if (!log.isInfoEnabled()) { return; } if (error == null) { log.info(expanded); } else { log.info(expanded, error); } break; case WARN: if (!log.isWarnEnabled()) { return; } if (error == null) { log.warn(expanded); } else { log.warn(expanded, error); } break; case ERROR: if (!log.isErrorEnabled()) { return; } if (error == null) { log.error(expanded); } else { log.error(expanded, error); } break; case FATAL: if (!log.isFatalEnabled()) { return; } if (error == null) { log.fatal(expanded); } else { log.fatal(expanded, error); } break; default: throw new IllegalArgumentException("The level '" + level + "' is unknown"); } }