List of usage examples for java.util.logging Logger log
public void log(Level level, Throwable thrown, Supplier<String> msgSupplier)
From source file:org.jdesktop.wonderland.modules.service.PendingManager.java
/** * Removes an existing module, given its name. *//* ww w . j ava 2 s .co m*/ public void remove(String moduleName) { Logger logger = ModuleManager.getLogger(); /* * Simply delete the directory associated with the module (quietly) and * remove from the list */ File file = new File(this.pendingFile, moduleName); try { FileUtils.deleteDirectory(file); } catch (IOException excp) { /* Log an error and continue */ logger.log(Level.WARNING, "[MODULES] PENDING Failed to remove " + file.getAbsolutePath(), excp); } this.pendingModules.remove(moduleName); }
From source file:util.Log.java
/** * Gera um arquivo log dentro da Pasta Logger que fica na Pasta principal do * Usuario.//from ww w .ja va 2s. co m * * @param className * @param ex */ public static void relatarExcecao(String className, Exception ex) { try { /* * Informamos qual o nome do Logger, que no caso vai ser o nome da * Classe que acontecer a exceo */ Logger log = Logger.getLogger(className); /* * Variavel que vai conter qual a pasta do sistema que liga ao * usuario, por padro ser do sistema operacional Windows */ String systemPath = "/Users/"; /* Se for outro sistema operacional */ if (System.getProperty("os.name").startsWith("Linux")) { systemPath = "/home/"; } /* Pasta onde vamos colocar os Logs */ File pastaLog = new File(systemPath + System.getProperty("user.name") + "/Logger"); if (!pastaLog.exists()) { pastaLog.mkdir(); } String arquivoDir = pastaLog.getAbsolutePath() + "/LOG_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd-MM_HH-mm-ss")) + ".log"; /* Classe responsavel por escrever o arquivo */ FileHandler escrever = new FileHandler(arquivoDir, true); /* * Precisamos informar como ser escrito(formato) as excees, Vamos * Utilizar uma Classe j pronta para isso a Classe SimpleFormatter */ escrever.setFormatter(new SimpleFormatter()); /* * Adicionamos ao nosso log a Classe que vai escrever a exceo que * for gerada */ log.addHandler(escrever); /* * Geramos o Log, passamos que ser de Nivel Severe(Alto), e * passamos a exceo para ele */ log.log(Level.SEVERE, null, ex); /* Finalizamos a escrita */ escrever.flush(); escrever.close(); /*Envia por email a exceo*/ Log.relatarExceptionEmail(className, ex.getMessage(), arquivoDir); } catch (IOException | SecurityException e) { Logger.getLogger(Log.class.getName()).log(Level.SEVERE, null, e); } }
From source file:com.qwazr.server.GenericServer.java
private void executeListener(final Collection<Listener> listeners, final Logger logger) { if (listeners == null) return;// w w w. j a v a 2s . c o m listeners.forEach(listener -> { try { listener.accept(this); } catch (Exception e) { if (logger == null) throw ServerException.of("Listeners failure", e); else LOGGER.log(Level.SEVERE, e, e::getMessage); } }); }
From source file:org.protempa.dest.table.Link.java
private boolean constraintsCheckCompatible(Proposition proposition, PropertyConstraint[] constraints) { Logger logger = Util.logger(); for (PropertyConstraint ccc : constraints) { String propName = ccc.getPropertyName(); Value value = proposition.getProperty(propName); if (value != null) { ValueComparator vc = ccc.getValueComparator(); if (logger.isLoggable(Level.FINER)) { logger.log(Level.FINER, "Proposition is {0}; Property is {1}; Value is {2}; Comparator: {3}", new Object[] { proposition.getId(), propName, value, vc }); }/*from w w w . j a v a 2 s . c o m*/ if (!vc.compare(value, ccc.getValue())) { return false; } } else { return false; } } return true; }
From source file:org.protempa.backend.dsb.relationaldb.AbstractSQLGenerator.java
private DataStager doStage(Collection<EntitySpec> allEntitySpecs, Filter filters, Set<String> propIds, Set<String> keyIds, SQLOrderBy order) throws DataSourceReadException { DataStager stager = null;/* w w w . j a v a 2 s . com*/ try { stager = getDataStager(this.stagedTableSpecs, null, new LinkedList<>(allEntitySpecs), copyFilters(filters), propIds, keyIds, order, this.connectionSpec); stager.stageTables(); } catch (SQLException ex) { Logger logger = SQLGenUtil.logger(); logger.log(Level.SEVERE, "Failed to create staging area", ex); throw new DataSourceReadException(ex); } return stager; }
From source file:org.protempa.backend.dsb.relationaldb.AbstractSQLGenerator.java
private void logDoneProcessing(Logger logger, EntitySpec entitySpec) { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Results of query for {0} in data source backend {1} " + "have been processed", new Object[] { entitySpec.getName(), backendNameForMessages() }); }/*from w ww . j a va 2s . c om*/ }
From source file:org.protempa.backend.dsb.relationaldb.AbstractSQLGenerator.java
private void logProcessingEntitySpec(Logger logger, EntitySpec entitySpec) { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Data source backend {0} is processing entity spec {1}", new Object[] { backendNameForMessages(), entitySpec.getName() }); }/*from ww w. jav a 2s . c o m*/ }
From source file:org.protempa.backend.dsb.relationaldb.AbstractSQLGenerator.java
@Override public final boolean loadDriverIfNeeded() { String className = getDriverClassNameToLoad(); if (className == null) { return true; }/*from w ww .jav a 2s . c o m*/ try { Class.forName(className); return true; } catch (ClassNotFoundException ex) { Logger logger = SQLGenUtil.logger(); if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "{0} when trying to load {1}.", new Object[] { ex.getClass().getName(), className }); } return false; } }
From source file:org.protempa.backend.dsb.relationaldb.AbstractSQLGenerator.java
private Map<EntitySpec, List<String>> entitySpecToPropIds(Set<String> propIds) throws AssertionError { Map<EntitySpec, List<String>> result = new HashMap<>(); for (String propId : propIds) { boolean inDataSource = populateEntitySpecToPropIdMap(new String[] { propId }, result); Logger logger = SQLGenUtil.logger(); if (!inDataSource && logger.isLoggable(Level.FINER)) { logger.log(Level.FINER, "Data source backend {0} does not know about proposition {1}", new Object[] { backendNameForMessages(), propId }); }/*from ww w. ja v a 2s . c o m*/ } return result; }
From source file:org.protempa.backend.dsb.relationaldb.RelationalDbDataSourceBackend.java
private void validate(KnowledgeSource knowledgeSource) throws KnowledgeSourceReadException, DataSourceBackendFailedConfigurationValidationException { List<EntitySpec> allSpecs = Arrays.asList(this.relationalDatabaseSpecBuilder.getEventSpecs(), this.relationalDatabaseSpecBuilder.getConstantSpecs(), this.relationalDatabaseSpecBuilder.getPrimitiveParameterSpecs()); Logger logger = SQLGenUtil.logger(); for (EntitySpec entitySpec : allSpecs) { String entitySpecName = entitySpec.getName(); logger.log(Level.FINER, "Validating entity spec {0}", entitySpecName); String[] propIds = entitySpec.getPropositionIds(); Set<String> propNamesFromPropSpecs = new HashSet<>(); PropertySpec[] propSpecs = entitySpec.getPropertySpecs(); logger.finer("Checking for duplicate properties"); for (PropertySpec propSpec : propSpecs) { String propSpecName = propSpec.getName(); if (!propNamesFromPropSpecs.add(propSpecName)) { throw new DataSourceBackendFailedConfigurationValidationException( "Duplicate property name " + propSpecName + " in entity spec " + entitySpecName); }/*from w w w . java 2 s. c om*/ } logger.finer("No duplicate properties found"); logger.finer("Checking for invalid proposition ids and properties"); Set<String> propNamesFromPropDefs = new HashSet<>(); Set<String> invalidPropIds = new HashSet<>(); for (String propId : propIds) { PropositionDefinition propDef = knowledgeSource.readPropositionDefinition(propId); if (propDef == null) { invalidPropIds.add(propId); } PropertyDefinition[] propertyDefs = propDef.getPropertyDefinitions(); for (PropertyDefinition propertyDef : propertyDefs) { String propName = propertyDef.getId(); propNamesFromPropDefs.add(propName); } } if (!invalidPropIds.isEmpty()) { throw new DataSourceBackendFailedConfigurationValidationException( "Invalid proposition id(s) named in entity spec " + entitySpecName + ": '" + StringUtils.join(invalidPropIds, "', '") + "'"); } if (!propNamesFromPropSpecs.removeAll(propNamesFromPropDefs)) { throw new DataSourceBackendFailedConfigurationValidationException( "Data model entity spec " + entitySpec.getName() + " has properties '" + StringUtils.join(propNamesFromPropSpecs, "', '") + "' that are not in the knowledge source's corresponding proposition definitions"); } logger.finer("No invalid proposition ids or properties found"); } }