Skip to content

Commit

Permalink
Use Slf4's Level instead of LoggerLevel (#28559)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Sep 23, 2023
1 parent 7d8c868 commit 3038697
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.props.TypedPropertyKey;
import org.slf4j.event.Level;

import java.util.Arrays;
import java.util.Collection;
Expand All @@ -36,7 +37,7 @@ public enum ConfigurationPropertyKey implements TypedPropertyKey {
/**
* The system log level.
*/
SYSTEM_LOG_LEVEL("system-log-level", LoggerLevel.INFO.name(), LoggerLevel.class, false),
SYSTEM_LOG_LEVEL("system-log-level", Level.INFO.toString(), Level.class, false),

/**
* Whether show SQL in log.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.jupiter.api.Test;
import org.slf4j.event.Level;

import java.util.Properties;

Expand All @@ -36,7 +37,7 @@ class ConfigurationPropertiesTest {
@Test
void assertGetValue() {
ConfigurationProperties actual = new ConfigurationProperties(createProperties());
assertThat(actual.getValue(ConfigurationPropertyKey.SYSTEM_LOG_LEVEL), is(LoggerLevel.DEBUG));
assertThat(actual.getValue(ConfigurationPropertyKey.SYSTEM_LOG_LEVEL), is(Level.DEBUG));
assertTrue((Boolean) actual.getValue(ConfigurationPropertyKey.SQL_SHOW));
assertTrue((Boolean) actual.getValue(ConfigurationPropertyKey.SQL_SIMPLE));
assertThat(actual.getValue(ConfigurationPropertyKey.KERNEL_EXECUTOR_SIZE), is(20));
Expand All @@ -54,7 +55,7 @@ void assertGetValue() {

private Properties createProperties() {
return PropertiesBuilder.build(
new Property(ConfigurationPropertyKey.SYSTEM_LOG_LEVEL.getKey(), LoggerLevel.DEBUG.toString()),
new Property(ConfigurationPropertyKey.SYSTEM_LOG_LEVEL.getKey(), Level.DEBUG.toString()),
new Property(ConfigurationPropertyKey.SQL_SHOW.getKey(), Boolean.TRUE.toString()),
new Property(ConfigurationPropertyKey.SQL_SIMPLE.getKey(), Boolean.TRUE.toString()),
new Property(ConfigurationPropertyKey.KERNEL_EXECUTOR_SIZE.getKey(), "20"),
Expand All @@ -73,7 +74,7 @@ private Properties createProperties() {
@Test
void assertGetDefaultValue() {
ConfigurationProperties actual = new ConfigurationProperties(new Properties());
assertThat(actual.getValue(ConfigurationPropertyKey.SYSTEM_LOG_LEVEL), is(LoggerLevel.INFO));
assertThat(actual.getValue(ConfigurationPropertyKey.SYSTEM_LOG_LEVEL), is(Level.INFO));
assertFalse((Boolean) actual.getValue(ConfigurationPropertyKey.SQL_SHOW));
assertFalse((Boolean) actual.getValue(ConfigurationPropertyKey.SQL_SIMPLE));
assertThat(actual.getValue(ConfigurationPropertyKey.KERNEL_EXECUTOR_SIZE), is(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apache.shardingsphere.distsql.parser.statement.ral.updatable.SetDistVariableStatement;
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import org.apache.shardingsphere.infra.config.props.LoggerLevel;
import org.apache.shardingsphere.infra.config.props.temporary.TemporaryConfigurationPropertyKey;
import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
import org.apache.shardingsphere.infra.instance.InstanceContext;
Expand All @@ -41,6 +40,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.slf4j.event.Level;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -88,7 +88,7 @@ void assertExecuteWithSystemLogLevel() {
updater.executeUpdate(connectionSession, statement);
Object actualValue = contextManager.getMetaDataContexts().getMetaData().getProps().getProps().get("system-log-level");
assertThat(actualValue.toString(), is("DEBUG"));
assertThat(contextManager.getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.SYSTEM_LOG_LEVEL), is(LoggerLevel.DEBUG));
assertThat(contextManager.getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.SYSTEM_LOG_LEVEL), is(Level.DEBUG));
}

@Test
Expand Down

0 comments on commit 3038697

Please sign in to comment.