List of usage examples for org.apache.commons.logging Log info
void info(Object message);
From source file:org.kuali.kra.logging.BufferedLogger.java
/** * Wraps {@link Log#info(String)}//w w w. j ava 2s .c o m * * @param pattern to format against * @param objs an array of objects used as parameters to the <code>pattern</code> */ public static final void info(Object... objs) { Log log = getLogger(); if (log.isInfoEnabled()) { log.info(getMessage(objs)); } }
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 *///from w ww . ja va2 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.util.Logs.java
public static void logThreadJoin(Thread thread) { Log log = LogFactory.getLog("org.lilyproject.threads.join"); if (!log.isInfoEnabled()) { return;// ww w .j ava 2 s. c o m } String context = ""; Exception e = new Exception(); e.fillInStackTrace(); StackTraceElement[] stackTrace = e.getStackTrace(); if (stackTrace.length >= 2) { context = stackTrace[1].toString(); } log.info("Waiting for thread to die: " + thread + " at " + context); }
From source file:org.mmadsen.sim.transmissionlab.population.SingleTraitPopulationFactory.java
public IAgentSet generatePopulation() { Log log = model.getLog(); String populationType = null; Integer numAgents = 0;/*ww w.j a va 2s. com*/ try { populationType = (String) this.model.getSimpleModelPropertyByName("initialTraitStructure"); numAgents = (Integer) this.model.getSimpleModelPropertyByName("numAgents"); } catch (RepastException ex) { System.out.println("FATAL EXCEPTION: " + ex.getMessage()); System.exit(1); } if (populationType == null) { log.info("No initial trait structure chosen, defaulting to SequentialTrait"); populationType = "SequentialTrait"; } if (populationType.equalsIgnoreCase("SequentialTrait")) { log.debug("Constructing UnstructuredSequentialTrait population"); return new UnstructuredSequentialTraits(numAgents, log); } else if (populationType.equalsIgnoreCase("GaussianTrait")) { log.debug("Constructing UnstructuredGaussianTrait population"); return new UnstructuredGaussianInitialTraits(numAgents, log); } // this should never happen but the method has to return SOMETHING in the code path return null; }
From source file:org.modelibra.util.Log4jConfigurator.java
public static void main(String[] args) { Log4jConfigurator log4jConfigurator = new Log4jConfigurator(); log4jConfigurator.configure();/* ww w . j av a2s .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.datademo.tools.ToolsMisc.java
/** * Utility which uses <code>info()</code> if the INFO log level is enabled, * else log as <code>warn()</code> * * @param inLog// w ww . ja v a 2 s . co m * @param inWhat * * @since 7.2 */ public static void forceLogInfo(org.apache.commons.logging.Log inLog, String inWhat) { if (inLog.isInfoEnabled()) { inLog.info(inWhat); } else { inLog.warn(inWhat); } }
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 w w . j a va 2 s. c o 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); }
From source file:org.opencms.pdftools.CmsXRLogAdapter.java
/** * Sends a log message to the commons-logging interface.<p> * * @param level the log level// ww w .ja va 2s.c om * @param message the message * @param log the commons logging log object * @param e a throwable or null */ private void sendMessageToLogger(Level level, String message, Log log, Throwable e) { if (e == null) { if (level == Level.SEVERE) { log.error(message); } else if (level == Level.WARNING) { log.warn(message); } else if (level == Level.INFO) { log.info(message); } else if (level == Level.CONFIG) { log.info(message); } else if ((level == Level.FINE) || (level == Level.FINER) || (level == Level.FINEST)) { log.debug(message); } else { log.info(message); } } else { if (level == Level.SEVERE) { log.error(message, e); } else if (level == Level.WARNING) { log.warn(message, e); } else if (level == Level.INFO) { log.info(message, e); } else if (level == Level.CONFIG) { log.info(message, e); } else if ((level == Level.FINE) || (level == Level.FINER) || (level == Level.FINEST)) { log.debug(message, e); } else { log.info(message, e); } } }
From source file:org.opendatakit.aggregate.odktables.security.OdkTablesUserInfoTable.java
public static synchronized final OdkTablesUserInfoTable getOdkTablesUserInfo(String uriUser, Set<GrantedAuthority> grants, CallingContext cc) throws ODKDatastoreException, ODKTaskLockException, ODKEntityPersistException, ODKOverQuotaException, PermissionDeniedException { Datastore ds = cc.getDatastore();/* ww w .ja v a2 s.c o m*/ OdkTablesUserInfoTable prototype = OdkTablesUserInfoTable.assertRelation(cc); Log log = LogFactory.getLog(FileManifestManager.class); log.info("TablesUserPermissionsImpl: " + uriUser); RoleHierarchy rh = (RoleHierarchy) cc.getBean(SecurityBeanDefs.ROLE_HIERARCHY_MANAGER); Collection<? extends GrantedAuthority> roles = rh.getReachableGrantedAuthorities(grants); boolean hasSynchronize = roles .contains(new SimpleGrantedAuthority(GrantedAuthorityName.ROLE_SYNCHRONIZE_TABLES.name())); boolean hasAdminister = roles .contains(new SimpleGrantedAuthority(GrantedAuthorityName.ROLE_ADMINISTER_TABLES.name())); if (hasSynchronize || hasAdminister) { String uriForUser = null; String externalUID = null; if (uriUser.equals(User.ANONYMOUS_USER)) { externalUID = User.ANONYMOUS_USER; uriForUser = User.ANONYMOUS_USER; } else { RegisteredUsersTable user = RegisteredUsersTable.getUserByUri(uriUser, ds, cc.getCurrentUser()); // Determine the external UID that will identify this user externalUID = null; if (user.getEmail() != null) { externalUID = user.getEmail(); } else if (user.getUsername() != null) { externalUID = SecurityUtils.USERNAME_COLON + user.getUsername(); } uriForUser = uriUser; } OdkTablesUserInfoTable odkTablesUserInfo = null; odkTablesUserInfo = OdkTablesUserInfoTable.getCurrentUserInfo(uriForUser, cc); if (odkTablesUserInfo == null) { // // GAIN LOCK LockTemplate tablesUserPermissions = new LockTemplate(externalUID, ODKTablesTaskLockType.TABLES_USER_PERMISSION_CREATION, cc); try { tablesUserPermissions.acquire(); // attempt to re-fetch the record. // If this succeeds, then we had multiple suitors; the other one beat // us. odkTablesUserInfo = OdkTablesUserInfoTable.getCurrentUserInfo(uriForUser, cc); if (odkTablesUserInfo != null) { return odkTablesUserInfo; } // otherwise, create a record odkTablesUserInfo = ds.createEntityUsingRelation(prototype, cc.getCurrentUser()); odkTablesUserInfo.setUriUser(uriForUser); odkTablesUserInfo.setOdkTablesUserId(externalUID); odkTablesUserInfo.persist(cc); return odkTablesUserInfo; } finally { tablesUserPermissions.release(); } } else { return odkTablesUserInfo; } } else { throw new PermissionDeniedException("User does not have access to ODK Tables"); } }
From source file:org.opendatakit.aggregate.server.ServerOdkTablesUtil.java
/** * Create a table in the datastore./* w ww.j a v a2 s . co m*/ * * @param appId * @param tableId * @param definition * @param cc * @return * @throws DatastoreFailureException * @throws TableAlreadyExistsExceptionClient * @throws PermissionDeniedExceptionClient * @throws ETagMismatchException */ public static TableEntryClient createTable(String appId, String tableId, TableDefinitionClient definition, TablesUserPermissions userPermissions, CallingContext cc) throws DatastoreFailureException, TableAlreadyExistsExceptionClient, PermissionDeniedExceptionClient, ETagMismatchException { Log logger = LogFactory.getLog(ServerOdkTablesUtil.class); // TODO: add access control stuff // Have to be careful of all the transforms going on here. // Make sure they actually work as expected! // also have to be sure that I am passing in an actual column and not a // column resource or something, in which case the transform() method is not // altering all of the requisite fields. try { TableManager tm = new TableManager(appId, userPermissions, cc); List<ColumnClient> columns = definition.getColumns(); List<Column> columnsServer = new ArrayList<Column>(); for (ColumnClient column : columns) { columnsServer.add(UtilTransforms.transform(column)); } TableEntry entry = tm.createTable(tableId, columnsServer); TableEntryClient entryClient = UtilTransforms.transform(entry); logger.info(String.format("tableId: %s, definition: %s", tableId, definition)); return entryClient; } catch (ODKDatastoreException e) { e.printStackTrace(); throw new DatastoreFailureException(e); } catch (TableAlreadyExistsException e) { e.printStackTrace(); throw new TableAlreadyExistsExceptionClient(e); } catch (PermissionDeniedException e) { e.printStackTrace(); throw new PermissionDeniedExceptionClient(e); } catch (ODKTaskLockException e) { e.printStackTrace(); throw new DatastoreFailureException(e); } }