public static void logFullStackTrace(final Level level, final Throwable t) { if (level == null || !LOGGER.isLoggable(level)) { return; } if (t == null) { return; } LOGGER.log(level, t.getMessage(), t); }
public static void logFullStackTrace(final Level level, final Throwable t) { if (level == null || !LOGGER.isLoggable(level)) { return; } if (t == null) { return; } LOGGER.log(level, t.getMessage(), t); }
private void showCommandline(final Path outputFile, final List<String> command) { if (!LOGGER.isLoggable(Level.SEVERE)) { return; } // Find name of DOT file in local directory final Path movedDotFile = outputFile.normalize().getParent() .resolve(outputFile.getFileName() + ".dot"); // Print command to run command.remove(command.size() - 1); command.remove(command.size() - 1); command.add(outputFile.toString()); command.add(movedDotFile.toString()); LOGGER.log(Level.SEVERE, String.format("%s%nGenerate your diagram manually, using:%n%s", readResourceFully("/dot.error.txt"), String.join(" ", command))); }
public static void logSystemProperties() { if (!LOGGER.isLoggable(Level.CONFIG)) { return; } final SortedMap<String, String> systemProperties = new TreeMap<>(); for (final Entry<Object, Object> propertyValue: System.getProperties() .entrySet()) { final String name = (String) propertyValue.getKey(); if ((name.startsWith("java.") || name.startsWith("os.")) && !name.endsWith(".path")) { systemProperties.put(name, (String) propertyValue.getValue()); } } LOGGER.log(Level.CONFIG, String.format("System properties: %n%s", join(systemProperties, System.lineSeparator()))); }
public static void logSystemProperties() { if (!LOGGER.isLoggable(Level.CONFIG)) { return; } final SortedMap<String, String> systemProperties = new TreeMap<>(); for (final Entry<Object, Object> propertyValue: System.getProperties() .entrySet()) { final String name = (String) propertyValue.getKey(); if ((name.startsWith("java.") || name.startsWith("os.")) && !name.endsWith(".path")) { systemProperties.put(name, (String) propertyValue.getValue()); } } LOGGER.log(Level.CONFIG, String.format("System properties: %n%s", join(systemProperties, System.lineSeparator()))); }
public static void logSystemClasspath() { if (!LOGGER.isLoggable(Level.CONFIG)) { return; } LOGGER.log(Level.CONFIG, String.format("Classpath: %n%s", printPath(System.getProperty("java.class.path")))); LOGGER.log(Level.CONFIG, String.format("LD_LIBRARY_PATH: %n%s", printPath(System.getenv("LD_LIBRARY_PATH")))); }
public static void logSystemClasspath() { if (!LOGGER.isLoggable(Level.CONFIG)) { return; } LOGGER.log(Level.CONFIG, String.format("Classpath: %n%s", printPath(System.getProperty("java.class.path")))); LOGGER.log(Level.CONFIG, String.format("LD_LIBRARY_PATH: %n%s", printPath(System.getenv("LD_LIBRARY_PATH")))); }
private void logConnection(final Connection connection) { if (connection == null || !LOGGER.isLoggable(Level.INFO)) { return; } try { final DatabaseMetaData dbMetaData = connection.getMetaData(); LOGGER .log(Level.INFO, new StringFormat("Connected to %n%s %s %nusing JDBC driver %n%s %s", dbMetaData.getDatabaseProductName(), dbMetaData.getDatabaseProductVersion(), dbMetaData.getDriverName(), dbMetaData.getDriverVersion())); } catch (final SQLException e) { LOGGER.log(Level.WARNING, "Could not log connection information", e); } }
private void logRegisteredJdbcDrivers() { if (!LOGGER.isLoggable(Level.CONFIG)) { return; } try { final StringBuilder buffer = new StringBuilder(1024); buffer.append("Registered JDBC drivers:"); for (final Driver driver: Collections.list(DriverManager.getDrivers())) { buffer.append(String.format("%n%s %d.%d", driver.getClass().getName(), driver.getMajorVersion(), driver.getMinorVersion())); } LOGGER.log(Level.CONFIG, buffer.toString()); } catch (final Exception e) { LOGGER.log(Level.FINE, "Could not log registered JDBC drivers", e); } }
/** * Releases this <code>ResultSet</code> object's database and JDBC * resources immediately instead of waiting for this to happen when it * is automatically closed. * * @throws SQLException * On an exception */ @Override public void close() throws SQLException { results.close(); if (LOGGER.isLoggable(Level.INFO) && !isBlank(description)) { LOGGER.log(Level.INFO, new StringFormat("Processed %d rows for <%s>", rowCount, description)); } }
/** * Releases this <code>ResultSet</code> object's database and JDBC * resources immediately instead of waiting for this to happen when it * is automatically closed. * * @throws SQLException * On an exception */ @Override public void close() throws SQLException { results.close(); if (LOGGER.isLoggable(Level.INFO) && !isBlank(description)) { LOGGER.log(Level.INFO, new StringFormat("Processed %d rows for <%s>", rowCount, description)); } }
private void logExecution() { if (LOGGER.isLoggable(Level.INFO)) { LOGGER .log(Level.INFO, String.format("Executing SchemaCrawler command <%s>", command)); if (LOGGER.isLoggable(Level.CONFIG)) { LOGGER.log(Level.CONFIG, String.format("Executable: %s", this.getClass().getName())); LOGGER.log(Level.CONFIG, ObjectToString.toString(schemaCrawlerOptions)); LOGGER.log(Level.CONFIG, ObjectToString.toString(outputOptions)); LOGGER.log(Level.CONFIG, schemaRetrievalOptions.toString()); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, ObjectToString.toString(additionalConfiguration)); } } } }
private static void logSQLWarnings(final SQLWarning sqlWarning) { final Level level = Level.FINER; if (!LOGGER.isLoggable(level)) { return; } SQLWarning currentSqlWarning = sqlWarning; while (currentSqlWarning != null) { final String message = String.format("%s%nError code: %d, SQL state: %s", currentSqlWarning.getMessage(), currentSqlWarning.getErrorCode(), currentSqlWarning.getSQLState()); LOGGER.log(level, message, currentSqlWarning); currentSqlWarning = currentSqlWarning.getNextWarning(); } }
private static void logSQLWarnings(final SQLWarning sqlWarning) { final Level level = Level.FINER; if (!LOGGER.isLoggable(level)) { return; } SQLWarning currentSqlWarning = sqlWarning; while (currentSqlWarning != null) { final String message = String.format("%s%nError code: %d, SQL state: %s", currentSqlWarning.getMessage(), currentSqlWarning.getErrorCode(), currentSqlWarning.getSQLState()); LOGGER.log(level, message, currentSqlWarning); currentSqlWarning = currentSqlWarning.getNextWarning(); } }
public static void logSQLWarnings(final Statement statement) { if (statement == null) { return; } if (!LOGGER.isLoggable(Level.INFO)) { return; } try { logSQLWarnings(statement.getWarnings()); statement.clearWarnings(); } catch (final SQLException e) { // NOTE: Do not show exception while logging warnings LOGGER.log(Level.WARNING, "Could not log SQL warnings for statement"); } }
public static void logSQLWarnings(final ResultSet resultSet) { if (resultSet == null) { return; } if (!LOGGER.isLoggable(Level.INFO)) { return; } try { logSQLWarnings(resultSet.getWarnings()); resultSet.clearWarnings(); } catch (final SQLException e) { // NOTE: Do not show exception while logging warnings LOGGER.log(Level.WARNING, "Could not log SQL warnings for result set"); } }
public static void logSQLWarnings(final Statement statement) { if (statement == null) { return; } if (!LOGGER.isLoggable(Level.INFO)) { return; } try { logSQLWarnings(statement.getWarnings()); statement.clearWarnings(); } catch (final SQLException e) { // NOTE: Do not show exception while logging warnings LOGGER.log(Level.WARNING, "Could not log SQL warnings for statement"); } }
public static void logSQLWarnings(final ResultSet resultSet) { if (resultSet == null) { return; } if (!LOGGER.isLoggable(Level.INFO)) { return; } try { logSQLWarnings(resultSet.getWarnings()); resultSet.clearWarnings(); } catch (final SQLException e) { // NOTE: Do not show exception while logging warnings LOGGER.log(Level.WARNING, "Could not log SQL warnings for result set"); } }
private void analyzeTables() { if (tables.isEmpty()) { return; } final Collection<String> prefixes = findTableNamePrefixes(tables); mapTableNameMatches(tables, prefixes); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, new StringFormat("Table prefixes=%s", prefixes)); LOGGER.log(Level.FINE, new StringFormat("Table matches map: %s", ObjectToString.toString(tableKeys))); } }
private void logScriptEngineDetails(final Level level, final ScriptEngineFactory scriptEngineFactory) { if (!LOGGER.isLoggable(level)) { return; } LOGGER .log(level, String .format("Using script engine%n%s %s (%s %s)%nScript engine names: %s%nSupported file extensions: %s", scriptEngineFactory.getEngineName(), scriptEngineFactory.getEngineVersion(), scriptEngineFactory.getLanguageName(), scriptEngineFactory.getLanguageVersion(), ObjectToString.toString(scriptEngineFactory.getNames()), ObjectToString .toString(scriptEngineFactory.getExtensions()))); }