Search in sources :

Example 1 with Level

use of org.flywaydb.core.internal.util.logging.console.ConsoleLog.Level in project killbill by killbill.

the class Migrator method main.

/**
     * Main method.
     *
     * @param args The command-line arguments.
     */
public static void main(final String[] args) {
    final Level logLevel = getLogLevel(args);
    initLogging(logLevel);
    try {
        if (isPrintVersionAndExit(args)) {
            printVersion();
            System.exit(0);
        }
        final List<String> operations = determineOperations(args);
        if (operations.isEmpty()) {
            printUsage();
            return;
        }
        final Properties properties = new Properties();
        initializeDefaults(properties);
        loadConfiguration(properties, args);
        overrideConfiguration(properties, args);
        dumpConfiguration(properties);
        loadJdbcDrivers();
        loadJavaMigrationsFromJarDirs(properties);
        final List<SqlStatement> sqlStatements = new LinkedList<SqlStatement>();
        final FlywayWithDryRun flyway = new FlywayWithDryRun(sqlStatements);
        filterProperties(properties);
        flyway.configure(properties);
        for (final String operation : operations) {
            executeOperation(flyway, operation, sqlStatements);
        }
    } catch (final Exception e) {
        if (logLevel == Level.DEBUG) {
            LOG.error("Unexpected error", e);
        } else {
            if (e instanceof FlywayException) {
                LOG.error(e.getMessage());
            } else {
                LOG.error(e.toString());
            }
        }
        System.exit(1);
    }
}
Also used : SqlStatement(org.flywaydb.core.internal.dbsupport.SqlStatement) FlywayException(org.flywaydb.core.api.FlywayException) FlywayWithDryRun(org.flywaydb.core.FlywayWithDryRun) Level(org.flywaydb.core.internal.util.logging.console.ConsoleLog.Level) Properties(java.util.Properties) LinkedList(java.util.LinkedList) FlywayException(org.flywaydb.core.api.FlywayException) IOException(java.io.IOException)

Example 2 with Level

use of org.flywaydb.core.internal.util.logging.console.ConsoleLog.Level in project flyway by flyway.

the class Main method main.

/**
     * Main method.
     *
     * @param args The command-line arguments.
     */
public static void main(String[] args) {
    Level logLevel = getLogLevel(args);
    initLogging(logLevel);
    try {
        printVersion();
        if (isPrintVersionAndExit(args)) {
            System.exit(0);
        }
        List<String> operations = determineOperations(args);
        if (operations.isEmpty()) {
            printUsage();
            return;
        }
        Properties properties = new Properties();
        initializeDefaults(properties);
        loadConfiguration(properties, args);
        overrideConfiguration(properties, args);
        if (!isSuppressPrompt(args)) {
            promptForCredentialsIfMissing(properties);
        }
        dumpConfiguration(properties);
        loadJdbcDrivers();
        loadJavaMigrationsFromJarDirs(properties);
        Flyway flyway = new Flyway();
        filterProperties(properties);
        flyway.configure(properties);
        for (String operation : operations) {
            executeOperation(flyway, operation);
        }
    } catch (Exception e) {
        if (logLevel == Level.DEBUG) {
            LOG.error("Unexpected error", e);
        } else {
            if (e instanceof FlywayException) {
                LOG.error(e.getMessage());
            } else {
                LOG.error(e.toString());
            }
        }
        System.exit(1);
    }
}
Also used : Flyway(org.flywaydb.core.Flyway) FlywayException(org.flywaydb.core.api.FlywayException) Level(org.flywaydb.core.internal.util.logging.console.ConsoleLog.Level) Properties(java.util.Properties) FlywayException(org.flywaydb.core.api.FlywayException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)2 Properties (java.util.Properties)2 FlywayException (org.flywaydb.core.api.FlywayException)2 Level (org.flywaydb.core.internal.util.logging.console.ConsoleLog.Level)2 LinkedList (java.util.LinkedList)1 Flyway (org.flywaydb.core.Flyway)1 FlywayWithDryRun (org.flywaydb.core.FlywayWithDryRun)1 SqlStatement (org.flywaydb.core.internal.dbsupport.SqlStatement)1