Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Slf4's Level instead of LoggerLevel #28559

Merged
merged 1 commit into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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