Merge branch '1.2.x'
This commit is contained in:
commit
45c39cf121
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -16,11 +16,9 @@
|
||||||
|
|
||||||
package org.springframework.boot.liquibase;
|
package org.springframework.boot.liquibase;
|
||||||
|
|
||||||
import liquibase.configuration.LiquibaseConfiguration;
|
|
||||||
import liquibase.logging.LogLevel;
|
import liquibase.logging.LogLevel;
|
||||||
import liquibase.logging.Logger;
|
import liquibase.logging.Logger;
|
||||||
import liquibase.logging.core.AbstractLogger;
|
import liquibase.logging.core.AbstractLogger;
|
||||||
import liquibase.logging.core.DefaultLoggerConfiguration;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
@ -30,6 +28,7 @@ import org.apache.commons.logging.LogFactory;
|
||||||
*
|
*
|
||||||
* @author Michael Cramer
|
* @author Michael Cramer
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
|
* @author Andy Wilkinson
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
public class CommonsLoggingLiquibaseLogger extends AbstractLogger {
|
public class CommonsLoggingLiquibaseLogger extends AbstractLogger {
|
||||||
|
|
@ -119,7 +118,7 @@ public class CommonsLoggingLiquibaseLogger extends AbstractLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isEnabled(LogLevel level) {
|
private boolean isEnabled(LogLevel level) {
|
||||||
if (this.logger != null && getLogLevel().compareTo(level) <= 0) {
|
if (this.logger != null) {
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case DEBUG:
|
case DEBUG:
|
||||||
return this.logger.isDebugEnabled();
|
return this.logger.isDebugEnabled();
|
||||||
|
|
@ -134,14 +133,4 @@ public class CommonsLoggingLiquibaseLogger extends AbstractLogger {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public LogLevel getLogLevel() {
|
|
||||||
LogLevel logLevel = super.getLogLevel();
|
|
||||||
if (logLevel == null) {
|
|
||||||
return toLogLevel(LiquibaseConfiguration.getInstance()
|
|
||||||
.getConfiguration(DefaultLoggerConfiguration.class).getLogLevel());
|
|
||||||
}
|
|
||||||
return logLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -31,6 +31,7 @@ import static org.mockito.Mockito.verify;
|
||||||
* Tests for {@link CommonsLoggingLiquibaseLogger}.
|
* Tests for {@link CommonsLoggingLiquibaseLogger}.
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
|
* @author Andy Wilkinson
|
||||||
*/
|
*/
|
||||||
public class CommonsLoggingLiquibaseLoggerTests {
|
public class CommonsLoggingLiquibaseLoggerTests {
|
||||||
|
|
||||||
|
|
@ -70,14 +71,6 @@ public class CommonsLoggingLiquibaseLoggerTests {
|
||||||
verify(this.delegate, never()).debug("debug");
|
verify(this.delegate, never()).debug("debug");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void debugBelowLevel() {
|
|
||||||
this.logger.setLogLevel(LogLevel.INFO);
|
|
||||||
given(this.delegate.isDebugEnabled()).willReturn(true);
|
|
||||||
this.logger.debug("debug", this.ex);
|
|
||||||
verify(this.delegate, never()).debug("debug", this.ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void info() {
|
public void info() {
|
||||||
this.logger.setLogLevel(LogLevel.INFO);
|
this.logger.setLogLevel(LogLevel.INFO);
|
||||||
|
|
@ -102,14 +95,6 @@ public class CommonsLoggingLiquibaseLoggerTests {
|
||||||
verify(this.delegate, never()).info("info");
|
verify(this.delegate, never()).info("info");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void infoBelowLevel() {
|
|
||||||
this.logger.setLogLevel(LogLevel.WARNING);
|
|
||||||
given(this.delegate.isInfoEnabled()).willReturn(true);
|
|
||||||
this.logger.info("info", this.ex);
|
|
||||||
verify(this.delegate, never()).info("info", this.ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void warning() {
|
public void warning() {
|
||||||
this.logger.setLogLevel(LogLevel.WARNING);
|
this.logger.setLogLevel(LogLevel.WARNING);
|
||||||
|
|
@ -134,14 +119,6 @@ public class CommonsLoggingLiquibaseLoggerTests {
|
||||||
verify(this.delegate, never()).warn("warning");
|
verify(this.delegate, never()).warn("warning");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void warningBelowLevel() {
|
|
||||||
this.logger.setLogLevel(LogLevel.SEVERE);
|
|
||||||
given(this.delegate.isWarnEnabled()).willReturn(true);
|
|
||||||
this.logger.warning("warning", this.ex);
|
|
||||||
verify(this.delegate, never()).warn("warning", this.ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void severe() {
|
public void severe() {
|
||||||
this.logger.setLogLevel(LogLevel.SEVERE);
|
this.logger.setLogLevel(LogLevel.SEVERE);
|
||||||
|
|
@ -166,14 +143,6 @@ public class CommonsLoggingLiquibaseLoggerTests {
|
||||||
verify(this.delegate, never()).error("severe");
|
verify(this.delegate, never()).error("severe");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void severeBelowLevel() {
|
|
||||||
this.logger.setLogLevel(LogLevel.OFF);
|
|
||||||
given(this.delegate.isErrorEnabled()).willReturn(true);
|
|
||||||
this.logger.severe("severe", this.ex);
|
|
||||||
verify(this.delegate, never()).error("severe", this.ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class MockCommonsLoggingLiquibaseLogger extends CommonsLoggingLiquibaseLogger {
|
private class MockCommonsLoggingLiquibaseLogger extends CommonsLoggingLiquibaseLogger {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue