mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Use AppLog and System.Logger for logging rather than slf4j-api
The avaje-applog-slf4j dependency means this is still using slf4j-api for implementation. Remove that dependency and service load the desired implementation.
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
package io.ebean.test;
|
||||
|
||||
import io.avaje.applog.AppLog;
|
||||
import io.ebeaninternal.api.SpiLogger;
|
||||
import io.ebeaninternal.api.SpiLoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.System.Logger.Level;
|
||||
|
||||
/**
|
||||
* Create a logger that captures the SQL and register it for later access in tests.
|
||||
@@ -15,7 +16,7 @@ public class CapturingLoggerFactory implements SpiLoggerFactory {
|
||||
|
||||
@Override
|
||||
public SpiLogger create(String name) {
|
||||
SpiLogger logger = new LogAdapter(LoggerFactory.getLogger(name));
|
||||
SpiLogger logger = new LogAdapter(AppLog.getLogger(name));
|
||||
if (name.equals("io.ebean.SQL")) {
|
||||
return LoggedSql.register(logger);
|
||||
}
|
||||
@@ -24,30 +25,30 @@ public class CapturingLoggerFactory implements SpiLoggerFactory {
|
||||
|
||||
private static final class LogAdapter implements SpiLogger {
|
||||
|
||||
private final Logger logger;
|
||||
private final System.Logger logger;
|
||||
|
||||
LogAdapter(Logger logger) {
|
||||
LogAdapter(System.Logger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebug() {
|
||||
return logger.isDebugEnabled();
|
||||
return logger.isLoggable(Level.DEBUG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTrace() {
|
||||
return logger.isTraceEnabled();
|
||||
return logger.isLoggable(Level.TRACE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String msg) {
|
||||
logger.debug(msg);
|
||||
logger.log(Level.DEBUG, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String msg) {
|
||||
logger.trace(msg);
|
||||
logger.log(Level.TRACE, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package io.ebean.test.config;
|
||||
|
||||
import io.avaje.applog.AppLog;
|
||||
import io.ebean.config.AutoConfigure;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.datasource.DataSourceConfig;
|
||||
import io.ebean.test.config.platform.PlatformAutoConfig;
|
||||
import io.ebean.test.config.provider.ProviderAutoConfig;
|
||||
import io.ebean.test.containers.DockerHost;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.System.Logger.Level;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@@ -21,7 +21,7 @@ import java.util.Properties;
|
||||
*/
|
||||
public class AutoConfigureForTesting implements AutoConfigure {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger("io.ebean.test");
|
||||
private static final System.Logger log = AppLog.getLogger("io.ebean.test");
|
||||
|
||||
/**
|
||||
* System property that can override the platform. mvn clean test -Ddb=sqlserver
|
||||
@@ -38,7 +38,7 @@ public class AutoConfigureForTesting implements AutoConfigure {
|
||||
io.avaje.config.Config.asConfiguration().evalModify(properties);
|
||||
}
|
||||
if (!config.isDefaultServer()) {
|
||||
log.info("skip automatic testing config on non-default server name:{} register:{}", config.getName(), config.isRegister());
|
||||
log.log(Level.INFO, "skip automatic testing config on non-default server name:{0} register:{1}", config.getName(), config.isRegister());
|
||||
return;
|
||||
}
|
||||
if (isExtraServer(config, properties)) {
|
||||
@@ -46,7 +46,7 @@ public class AutoConfigureForTesting implements AutoConfigure {
|
||||
return;
|
||||
}
|
||||
String testPlatform = properties.getProperty("ebean.test.platform");
|
||||
log.debug("automatic testing config - with ebean.test.platform:{} name:{} environmentDb:{}", testPlatform, config.getName(), environmentDb);
|
||||
log.log(Level.DEBUG, "automatic testing config - with ebean.test.platform:{0} name:{1} environmentDb:{2}", testPlatform, config.getName(), environmentDb);
|
||||
if (RunOnceMarker.isRun()) {
|
||||
setupPlatform(environmentDb, config);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package io.ebean.test.config.platform;
|
||||
|
||||
import io.avaje.applog.AppLog;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.datasource.DataSourceConfig;
|
||||
import io.ebean.test.containers.DockerHost;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.System.Logger.Level;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,7 @@ import java.util.Properties;
|
||||
*/
|
||||
class Config {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger("io.ebean.test");
|
||||
private static final System.Logger log = AppLog.getLogger("io.ebean.test");
|
||||
|
||||
/**
|
||||
* Common optional docker parameters that we just transfer to docker properties.
|
||||
@@ -193,7 +193,7 @@ class Config {
|
||||
ds.setDriver(driverClass);
|
||||
config.setDataSourceConfig(ds);
|
||||
|
||||
log.info("Using jdbc settings - username:{} url:{} driver:{}", ds.getUsername(), ds.getUrl(), ds.getDriver());
|
||||
log.log(Level.INFO, "Using jdbc settings - username:{0} url:{1} driver:{2}", ds.getUsername(), ds.getUrl(), ds.getDriver());
|
||||
|
||||
if (driverClass != null) {
|
||||
try {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package io.ebean.test.config.platform;
|
||||
|
||||
import io.avaje.applog.AppLog;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.test.containers.ContainerFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.System.Logger.Level;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
@@ -14,7 +14,7 @@ import static java.util.concurrent.CompletableFuture.runAsync;
|
||||
|
||||
public class PlatformAutoConfig {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger("io.ebean.test");
|
||||
private static final System.Logger log = AppLog.getLogger("io.ebean.test");
|
||||
|
||||
/**
|
||||
* Known platforms we can setup locally or via docker container.
|
||||
@@ -62,7 +62,7 @@ public class PlatformAutoConfig {
|
||||
|
||||
Config config = new Config(db, platform, databaseName, this.config);
|
||||
platformSetup.setupExtraDbDataSource(config);
|
||||
log.debug("configured dataSource for extraDb name:{} url:{}", db, this.config.getDataSourceConfig().getUrl());
|
||||
log.log(Level.DEBUG, "configured dataSource for extraDb name:{0} url:{1}", db, this.config.getDataSourceConfig().getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,9 +92,9 @@ public class PlatformAutoConfig {
|
||||
Properties dockerProperties = platformSetup.setup(config);
|
||||
if (!dockerProperties.isEmpty()) {
|
||||
if (isDebug()) {
|
||||
log.info("Docker properties: {}", dockerProperties);
|
||||
log.log(Level.INFO, "Docker properties: {0}", dockerProperties);
|
||||
} else {
|
||||
log.debug("Docker properties: {}", dockerProperties);
|
||||
log.log(Level.DEBUG, "Docker properties: {0}", dockerProperties);
|
||||
}
|
||||
// start the docker container with appropriate configuration
|
||||
new ContainerFactory(dockerProperties, config.getDockerPlatform()).startContainers();
|
||||
@@ -130,7 +130,7 @@ public class PlatformAutoConfig {
|
||||
}
|
||||
this.platformSetup = KNOWN_PLATFORMS.get(platform);
|
||||
if (platformSetup == null) {
|
||||
log.warn("unknown platform {} - skipping platform setup", platform);
|
||||
log.log(Level.WARNING, "unknown platform {0} - skipping platform setup", platform);
|
||||
}
|
||||
return platformSetup != null;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package io.ebean.test.config.provider;
|
||||
|
||||
import io.avaje.applog.AppLog;
|
||||
import io.ebean.config.CurrentTenantProvider;
|
||||
import io.ebean.config.CurrentUserProvider;
|
||||
import io.ebean.config.DatabaseConfig;
|
||||
import io.ebean.config.EncryptKeyManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.System.Logger.Level;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@@ -14,7 +14,7 @@ import java.util.Properties;
|
||||
*/
|
||||
public class ProviderAutoConfig {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger("io.ebean.test");
|
||||
private static final System.Logger log = AppLog.getLogger("io.ebean.test");
|
||||
|
||||
private final DatabaseConfig config;
|
||||
private final Properties properties;
|
||||
@@ -44,12 +44,12 @@ public class ProviderAutoConfig {
|
||||
if (keyManager == null) {
|
||||
// Must be 16 Chars for Oracle function
|
||||
String keyVal = properties.getProperty("ebean.test.encryptKey", "simple0123456789");
|
||||
log.debug("for testing - using FixedEncryptKeyManager() keyVal:{}", keyVal);
|
||||
log.log(Level.DEBUG, "for testing - using FixedEncryptKeyManager() keyVal:{0}", keyVal);
|
||||
config.setEncryptKeyManager(new FixedEncryptKeyManager(keyVal));
|
||||
}
|
||||
|
||||
if (providerSetFlag > 0) {
|
||||
log.info(msg(providerSetFlag));
|
||||
log.log(Level.INFO, msg(providerSetFlag));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ module io.ebean.test {
|
||||
provides io.ebeaninternal.api.SpiLoggerFactory with io.ebean.test.CapturingLoggerFactory;
|
||||
provides io.ebean.config.AutoConfigure with io.ebean.test.config.AutoConfigureForTesting;
|
||||
|
||||
requires transitive org.slf4j;
|
||||
requires transitive io.ebean.datasource;
|
||||
requires transitive io.ebean.core;
|
||||
requires transitive io.ebean.ddl.generator;
|
||||
@@ -24,6 +23,7 @@ module io.ebean.test {
|
||||
requires transitive com.h2database;
|
||||
|
||||
// support testing
|
||||
requires static org.slf4j;
|
||||
requires static org.junit.jupiter.api;
|
||||
requires static jdk.management;
|
||||
requires static io.avaje.jsr305x;
|
||||
|
||||
Reference in New Issue
Block a user