List of usage examples for org.apache.commons.logging Log error
void error(Object message);
From source file:org.iai.rosjava_interactive.interactive_markers_java_test.MarkerTester.java
@Override public void onStart(ConnectedNode cn) { final Log log = cn.getLog(); this.node = cn; server = new InteractiveMarkerServer(node, "simple_marker"); log.info("Generating Maker"); InteractiveMarker int_marker = node.getTopicMessageFactory().newFromType(InteractiveMarker._TYPE); int_marker.getHeader().setFrameId("base_link"); int_marker.getHeader().setStamp(node.getCurrentTime()); int_marker.setName("my_marker"); int_marker.setDescription("Simple 1-DOF Control"); log.info("Appending Box"); Marker boxMarker = node.getTopicMessageFactory().newFromType(Marker._TYPE); boxMarker.setType(Marker.CUBE);/*from w w w. j a va2 s . co m*/ boxMarker.getScale().setX(0.5); boxMarker.getScale().setY(0.5); boxMarker.getScale().setZ(0.5); boxMarker.getColor().setR(1f); boxMarker.getColor().setG(0.05f); boxMarker.getColor().setB(0.25f); boxMarker.getColor().setA(1f); log.error("AppendingBoxControl"); InteractiveMarkerControl boxControl = node.getTopicMessageFactory() .newFromType(InteractiveMarkerControl._TYPE); boxControl.setAlwaysVisible(true); boxControl.getMarkers().add(boxMarker); int_marker.getControls().add(boxControl); log.error("AppendingRotateBoxControl"); InteractiveMarkerControl boxRotateControl = node.getTopicMessageFactory() .newFromType(InteractiveMarkerControl._TYPE); boxRotateControl.setName("move_x"); boxRotateControl.setInteractionMode(InteractiveMarkerControl.MOVE_AXIS); int_marker.getControls().add(boxRotateControl); log.error("AppendingFeedback"); server.insert(int_marker, new MarkerFeedback() { @Override public void handleMarkerFeedback(InteractiveMarkerFeedback feedback) { log.info("FEEDBACK: " + feedback.getControlName()); } }, InteractiveMarkerServer.DEFAULT_FEEDBACK_CB); log.error("Apply changes"); server.applyChanges(); node.executeCancellableLoop(new CancellableLoop() { @Override protected void setup() { } @Override protected void loop() throws InterruptedException { Thread.sleep(1000); } }); /* Subscriber<std_msgs.String> subscriber = node.newSubscriber("chatter", std_msgs.String._TYPE); subscriber.addMessageListener(new MessageListener<std_msgs.String>() { @Override public void onNewMessage(std_msgs.String message) { log.info("I heard: \"" + message.getData() + "\""); } }); */ }
From source file:org.inwiss.platform.common.util.StringUtil.java
/** * Encodes a string using algorithm specified in web.xml and return the * resulting encrypted password. If exception, the plain credentials * string is returned//from w ww .j a v a 2s. c o m * * @param password Password or other credentials to use in authenticating * this username * @param algorithm Algorithm used to do the digest * @return encypted password based on the algorithm. */ public static String encodePassword(String password, String algorithm) { if (password == null) { return null; } Log log = LogFactory.getLog(StringUtil.class); byte[] unencodedPassword = password.getBytes(); MessageDigest md; try { // first create an instance, given the provider md = MessageDigest.getInstance(algorithm); } catch (Exception e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); if (log.isErrorEnabled()) { log.error(sw.toString()); } return password; } md.reset(); // call the update method one or more times // (useful when you don't know the size of your data, e.g. stream) md.update(unencodedPassword); // now calculate the hash byte[] encodedPassword = md.digest(); StringBuffer buf = new StringBuffer(); for (int i = 0; i < encodedPassword.length; i++) { if ((encodedPassword[i] & 0xff) < 0x10) { buf.append("0"); } buf.append(Long.toString(encodedPassword[i] & 0xff, 16)); } return buf.toString(); }
From source file:org.iwethey.forums.domain.OldQuote.java
public void logMe(Log logger) { logger.error("POST: " + toString()); }
From source file:org.jboss.netty.logging.CommonsLoggerTest.java
@Test public void testError() { org.apache.commons.logging.Log mock = createStrictMock(org.apache.commons.logging.Log.class); mock.error("a"); replay(mock);/*from w w w. j a v a 2 s .c o m*/ InternalLogger logger = new CommonsLogger(mock, "foo"); logger.error("a"); verify(mock); }
From source file:org.jboss.set.aphrodite.common.Utils.java
public static void logException(Log log, String message, Exception e) { if (log.isErrorEnabled()) { if (message == null) log.error(e); else//from w w w . j a v a2 s .c o m log.error(message, e); } }
From source file:org.jkcsoft.java.util.JndiHelper.java
public static void logLdap(Log plog, int level, int nth, Object dirEntry) throws NamingException { try {/* w w w . jav a2 s . c o m*/ if (dirEntry instanceof NamingEnumeration) { NamingEnumeration nameEnum = (NamingEnumeration) dirEntry; JndiHelper.logLevel(plog, level, nth, "Naming Enumeration: " + nameEnum); try { int nthThis = 0; List nameList = new Vector(Collections.list(nameEnum)); Collections.sort(nameList, new Comparator() { public int compare(Object o1, Object o2) { if (o1 instanceof Attribute) { return String.CASE_INSENSITIVE_ORDER.compare(((Attribute) o1).getID(), ((Attribute) o2).getID()); } return 0; } }); Iterator nameIter = nameList.iterator(); while (nameIter.hasNext()) { logLdap(plog, level + 1, nthThis++, nameIter.next()); } } catch (NamingException ex) { plog.error("Exception iterating thru NamingEnumeration: " + ex.getMessage()); } } else if (dirEntry instanceof Attribute) { Attribute dirAttr = (Attribute) dirEntry; JndiHelper.logLevel(plog, level, nth, "Attribute: [" + dirAttr + "]"); } else if (dirEntry instanceof DirContext) { DirContext lctx = (DirContext) dirEntry; JndiHelper.logLevel(plog, level, nth, "LDAP Context: DN [" + lctx.getNameInNamespace() + "]" + " Attributes ==>"); logLdap(plog, level, nth, lctx.getAttributes("").getAll()); } else if (dirEntry instanceof SearchResult) { SearchResult sr = (SearchResult) dirEntry; JndiHelper.logLevel(plog, level, nth, "SearchResult: ClassName of Bound Object [" + sr.getClassName() + "]" + " Name: [" + sr.getName() + "]" + " Bound Object ==>"); // sr.s logLdap(plog, level, nth, sr.getObject()); logLdap(plog, level, nth, sr.getAttributes().getAll()); } else { JndiHelper.logLevel(plog, level, nth, "(?) class of entry: [" + dirEntry + "]"); } nth++; } catch (NamingException e1) { plog.error("Naming Exception (will try to continue): " + e1.getMessage()); } }
From source file:org.kuali.rice.krad.datadictionary.validator.ValidationController.java
/** * Writes the results of the validation to an output file * * @param log - The Log4j logger the output is sent to * @param validator - The filled validator * @param passed - Whether the validation passed or not */// w ww. ja v a 2 s. c o m protected void writeToLog(Log log, Validator validator, boolean passed) { log.info("Passed: " + passed); if (displayErrors) { log.info("Number of Errors: " + validator.getNumberOfErrors()); } if (displayWarnings) { log.info("Number of Warnings: " + validator.getNumberOfWarnings()); } if (displayErrorMessages) { for (int i = 0; i < validator.getErrorReportSize(); i++) { if (validator.getErrorReport(i).getErrorStatus() == ErrorReport.ERROR) { if (displayXmlPages) { log.error(validator.getErrorReport(i).errorMessage() + validator.getErrorReport(i).errorPageList()); } else { log.error(validator.getErrorReport(i).errorMessage()); } } else { if (displayWarningMessages) { if (displayXmlPages) { log.warn(validator.getErrorReport(i).errorMessage() + validator.getErrorReport(i).errorPageList()); } else { log.warn(validator.getErrorReport(i).errorMessage()); } } } } } }
From source file:org.lilyproject.runtime.classloading.ClassLoaderBuilder.java
public static synchronized ClassLoader build(List<ClasspathEntry> classpathEntries, ClassLoader parentClassLoader, ArtifactRepository repository) throws ArtifactNotFoundException, MalformedURLException { if (classLoaderCacheEnabled) { ///*from w w w .j a v a 2 s. co m*/ // About the ClassLoader cache: // The ClassLoader cache was introduced to handle leaks in the 'Perm Gen' and 'Code Cache' // JVM memory spaces when repeatedly restarting Lily Runtime within the same JVM. In such cases, // on each restart Lily Runtime would construct new class loaders, hence the classes loaded through // them would be new and would stress those JVM memory spaces. // // The solution here is good enough for what it is intended to do (restarting the same Lily Runtime // app, unchanged, many times). There is no cache cleaning and the cache key calculation // is not perfect, so if you would enable the cache when starting a wide variety of Lily Runtime // apps within one VM or for reloading changed Lily Runtime apps, it could be problematic. // StringBuilder cacheKeyBuilder = new StringBuilder(2000); for (ClasspathEntry entry : classpathEntries) { cacheKeyBuilder.append(entry.getArtifactRef()).append("\u2603" /* unicode snowman as separator */); } // Add some identification of the parent class loader if (parentClassLoader instanceof URLClassLoader) { for (URL url : ((URLClassLoader) parentClassLoader).getURLs()) { cacheKeyBuilder.append(url.toString()); } } String cacheKey = cacheKeyBuilder.toString(); ClassLoader classLoader = classLoaderCache.get(cacheKey); if (classLoader == null) { Log log = LogFactory.getLog(ClassLoaderBuilder.class); log.debug("Creating and caching a new classloader"); classLoader = create(classpathEntries, parentClassLoader, repository); classLoaderCache.put(cacheKey, classLoader); } else if (classLoader.getParent() != parentClassLoader) { Log log = LogFactory.getLog(ClassLoaderBuilder.class); log.error("Lily Runtime ClassLoader cache: parentClassLoader of cache ClassLoader is different" + " from the specified one. Returning the cached one anyway."); } return classLoader; } else { return create(classpathEntries, parentClassLoader, repository); } }
From source file:org.modelibra.util.Log4jConfigurator.java
public static void main(String[] args) { Log4jConfigurator log4jConfigurator = new Log4jConfigurator(); log4jConfigurator.configure();// w ww. j a v a2 s .c o m Log log = LogFactory.getLog(Log4jConfigurator.class); log.info("Check if log4j works for info."); // Goes to info.html and not to error.html!? log.error("Check if log4j works for error."); }
From source file:org.nuxeo.ecm.automation.core.operations.LogOperation.java
@OperationMethod public void run() { if (category == null) { category = "org.nuxeo.ecm.automation.logger"; }//from w ww. j a v a2 s .co m Log log = LogFactory.getLog(category); if ("debug".equals(level)) { log.debug(message); return; } if ("warn".equals(level)) { log.warn(message); return; } if ("error".equals(level)) { log.error(message); return; } // in any other case, use info log level log.info(message); }