本文整理汇总了Java中liquibase.logging.LogFactory类的典型用法代码示例。如果您正苦于以下问题:Java LogFactory类的具体用法?Java LogFactory怎么用?Java LogFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LogFactory类属于liquibase.logging包,在下文中一共展示了LogFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLiquibase
import liquibase.logging.LogFactory; //导入依赖的package包/类
private Liquibase getLiquibase(Connection connection) throws Exception {
ServiceLocator sl = ServiceLocator.getInstance();
if (!System.getProperties().containsKey("liquibase.scan.packages")) {
if (sl.getPackages().remove("liquibase.core")) {
sl.addPackageToScan("liquibase.core.xml");
}
if (sl.getPackages().remove("liquibase.parser")) {
sl.addPackageToScan("liquibase.parser.core.xml");
}
if (sl.getPackages().remove("liquibase.serializer")) {
sl.addPackageToScan("liquibase.serializer.core.xml");
}
sl.getPackages().remove("liquibase.ext");
sl.getPackages().remove("liquibase.sdk");
}
LogFactory.setInstance(new LogWrapper());
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
return new Liquibase(CHANGELOG, new ClassLoaderResourceAccessor(getClass().getClassLoader()), database);
}
示例2: close
import liquibase.logging.LogFactory; //导入依赖的package包/类
@Override
public void close() throws DatabaseException {
// copy-paste from AbstractJdbcDatabase plus reflection to deal with private fields...
ExecutorService.getInstance().clearExecutor(this);
DatabaseConnection connection = getConnection();
if (connection != null) {
Boolean previousAutoCommit = previousAutoCommit();
if (previousAutoCommit != null) {
try {
connection.setAutoCommit(previousAutoCommit);
} catch (DatabaseException e) {
LogFactory.getInstance().getLog().warning("Failed to restore the auto commit to " + previousAutoCommit);
throw e;
}
}
connection.close();
}
}
示例3: generateSql
import liquibase.logging.LogFactory; //导入依赖的package包/类
public Sql[] generateSql(DropTableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
StringBuffer buffer = new StringBuffer();
buffer.append("DROP TABLE ").append(database.escapeTableName(statement.getSchemaName(), statement.getTableName()));
if (statement.isCascadeConstraints()) {
if (!database.supportsDropTableCascadeConstraints()) {
LogFactory.getLogger().warning("Database does not support drop with cascade");
} else if (database instanceof OracleDatabase) {
buffer.append(" CASCADE CONSTRAINTS");
} else {
buffer.append(" CASCADE");
}
}
return new Sql[]{
new UnparsedSql(buffer.toString())
};
}
示例4: setConnection
import liquibase.logging.LogFactory; //导入依赖的package包/类
@Override
public void setConnection(DatabaseConnection conn) {
try {
Method wrappedConn = conn.getClass().getMethod("getWrappedConnection");
wrappedConn.setAccessible(true);
Connection sqlConn = (Connection)wrappedConn.invoke(conn);
Method method = sqlConn.getClass().getMethod("setRemarksReporting", Boolean.TYPE);
method.setAccessible(true);
method.invoke(sqlConn, true);
reservedWords.addAll(Arrays.asList(sqlConn.getMetaData().getSQLKeywords().toUpperCase().split(",\\s*")));
reservedWords.addAll(Arrays.asList("USER", "SESSION","RESOURCE")); //more reserved words not returned by driver
} catch (Exception e) {
LogFactory.getLogger().info("Could not set remarks reporting on OracleDatabase: "+e.getMessage());
; //cannot set it. That is OK
}
super.setConnection(conn);
}
示例5: validate
import liquibase.logging.LogFactory; //导入依赖的package包/类
public void validate(Database database, String... contexts) throws LiquibaseException {
ChangeLogIterator logIterator = new ChangeLogIterator(this, new DbmsChangeSetFilter(database), new ContextChangeSetFilter(contexts));
ValidatingVisitor validatingVisitor = new ValidatingVisitor(database.getRanChangeSetList());
validatingVisitor.validate(database, this);
logIterator.run(validatingVisitor, database);
for (String message : validatingVisitor.getWarnings().getMessages()) {
LogFactory.getLogger().warning(message);
}
if (!validatingVisitor.validationPassed()) {
throw new ValidationFailedException(validatingVisitor);
}
}
示例6: computeMD5
import liquibase.logging.LogFactory; //导入依赖的package包/类
public static String computeMD5(String input) {
if (input == null) {
return null;
}
MessageDigest digest;
try {
digest = MessageDigest.getInstance("MD5");
digest.update(input.getBytes("UTF-8"));
} catch (Exception e) {
throw new UnexpectedLiquibaseException(e);
}
byte[] digestBytes = digest.digest();
String returnString = new String(encodeHex(digestBytes));
LogFactory.getLogger().debug("Computed checksum for "+input+" as "+returnString);
return returnString;
}
示例7: init
import liquibase.logging.LogFactory; //导入依赖的package包/类
@Override
public void init() throws SetupException {
if (path == null) {
throw new SetupException("<sqlfile> - No path specified");
}
LogFactory.getLogger().debug("SQLFile file:" + path);
boolean loaded = loadFromClasspath(path);
if (!loaded) {
loaded = loadFromFileSystem(path);
}
if (!loaded) {
throw new SetupException("<sqlfile path=" + path + "> - Could not find file");
}
LogFactory.getLogger().debug("SQLFile file contents is:" + getSql());
}
示例8: validate
import liquibase.logging.LogFactory; //导入依赖的package包/类
public ValidationErrors validate(Database database) {
ValidationErrors changeValidationErrors = new ValidationErrors();
for (SqlStatement statement : generateStatements(database)) {
boolean supported = SqlGeneratorFactory.getInstance().supports(statement, database);
if (!supported) {
if (statement.skipOnUnsupported()) {
LogFactory.getLogger().info(getChangeMetaData().getName()+" is not supported on "+database.getTypeName()+" but will continue");
} else {
changeValidationErrors.addError(getChangeMetaData().getName()+" is not supported on "+database.getTypeName());
}
} else {
changeValidationErrors.addAll(SqlGeneratorFactory.getInstance().validate(statement, database));
}
}
return changeValidationErrors;
}
示例9: generateSql
import liquibase.logging.LogFactory; //导入依赖的package包/类
public Sql[] generateSql(final CreateIndexStatement statement, final Database database, final SqlGeneratorChain sqlGeneratorChain) {
final Sql[] superSql = super.generateSql(statement, database, sqlGeneratorChain);
if (statement instanceof CreateIndexWithWhereStatement) {
if (superSql.length != 1) {
LogFactory.getLogger().warning("expected 1 create index statement, but got " + superSql.length);
return superSql;
}
return new Sql[] {
new UnparsedSql(superSql[0].toSql() + " WHERE " + ((CreateIndexWithWhereStatement)statement).getWhere(),
superSql[0].getEndDelimiter(), superSql[0].getAffectedDatabaseObjects().toArray(new DatabaseObject[0]))
};
} else {
return superSql;
}
}
示例10: performDatabaseSetupOrClean
import liquibase.logging.LogFactory; //导入依赖的package包/类
private void performDatabaseSetupOrClean(boolean setup) {
try {
ResourceAccessor resourceAccessor = new FileSystemResourceAccessor();
Class.forName(getJdbcDriverClassname());
Connection holdingConnection = DriverManager.getConnection(getJdbcConnectionString(), getDbUsername(), getDbPassword());
HsqlConnection hsconn = new HsqlConnection(holdingConnection);
LogFactory.getLogger().setLogLevel("warning");
Liquibase liquibase = new Liquibase(CHANGE_LOG, resourceAccessor, hsconn);
liquibase.dropAll();
if (setup) {
liquibase.update("test");
liquibase = new Liquibase(TEST_DATA_CHANGE_LOG, resourceAccessor, hsconn);
liquibase.update("test");
}
hsconn.close();
} catch (Exception ex) {
String msg = setup ? "Error during database initialization" : "Error during database clean-up";
LOG.error(msg, ex);
throw new RuntimeException(msg, ex);
}
}
示例11: AbstractIntegrationTest
import liquibase.logging.LogFactory; //导入依赖的package包/类
protected AbstractIntegrationTest(String changelogDir, String url) throws Exception {
LogFactory.setLoggingLevel("info");
this.completeChangeLog = "changelogs/" + changelogDir + "/complete/root.changelog.xml";
this.rollbackChangeLog = "changelogs/" + changelogDir + "/rollback/rollbackable.changelog.xml";
this.includedChangeLog = "changelogs/" + changelogDir + "/complete/included.changelog.xml";
this.encodingChangeLog = "changelogs/common/encoding.changelog.xml";
this.externalfkInitChangeLog= "changelogs/common/externalfk.init.changelog.xml";
this.externalEntityChangeLog= "changelogs/common/externalEntity.changelog.xml";
this.externalEntityChangeLog2= "com/example/nonIncluded/externalEntity.changelog.xml";
this.invalidReferenceChangeLog= "changelogs/common/invalid.reference.changelog.xml";
this.objectQuotingStrategyChangeLog = "changelogs/common/object.quoting.strategy.changelog.xml";
this.url = url;
ServiceLocator.getInstance().setResourceAccessor(TestContext.getInstance().getTestResourceAccessor());
}
示例12: changeLogLevel
import liquibase.logging.LogFactory; //导入依赖的package包/类
public void changeLogLevel(String logLevel, String logFile) throws CommandLineParsingException {
ParamUtil.requireNonNull("logLevel", logLevel);
try {
Logger log = LogFactory.getInstance().getLog();
if (logFile != null && logFile.length() > 0) {
log.setLogLevel(logLevel, logFile);
} else {
log.setLogLevel(logLevel);
}
} catch (IllegalArgumentException ex) {
throw new CommandLineParsingException(ex.getMessage(), ex);
}
}
示例13: shutdown
import liquibase.logging.LogFactory; //导入依赖的package包/类
public void shutdown() {
try {
if (database != null) {
database.rollback();
database.close();
}
} catch (DatabaseException ex) {
LogFactory.getInstance().getLog().warning("problem closing connection", ex);
} finally {
database = null;
liquibase = null;
}
}
示例14: setupLogging
import liquibase.logging.LogFactory; //导入依赖的package包/类
protected void setupLogging() {
LogFactory.setInstance(new LogFactory() {
@Override
public liquibase.logging.Logger getLog(String name) {
return loggerAdapter;
}
});
}
示例15: getConnectionCatalogName
import liquibase.logging.LogFactory; //导入依赖的package包/类
@Override
protected String getConnectionCatalogName() throws DatabaseException {
try {
return ExecutorService.getInstance().getExecutor(this).queryForObject(new RawSqlStatement("select current schema from sysibm.sysdummy1"), String.class);
} catch (Exception e) {
LogFactory.getLogger().info("Error getting default schema", e);
}
return null;
}