From 303869781fa84c3af4afd0138b82925e2fccacd7 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Sat, 23 Sep 2023 22:10:36 +0800 Subject: [PATCH] Use Slf4's Level instead of LoggerLevel (#28559) --- .../props/ConfigurationPropertyKey.java | 3 ++- .../infra/config/props/LoggerLevel.java | 26 ------------------- .../props/ConfigurationPropertiesTest.java | 7 ++--- .../updatable/SetDistVariableUpdaterTest.java | 4 +-- 4 files changed, 8 insertions(+), 32 deletions(-) delete mode 100644 infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/LoggerLevel.java diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertyKey.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertyKey.java index e2fcfca568806..b731cd9a2f883 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertyKey.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertyKey.java @@ -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; @@ -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. diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/LoggerLevel.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/LoggerLevel.java deleted file mode 100644 index 48e757303777b..0000000000000 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/config/props/LoggerLevel.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.infra.config.props; - -/** - * Logger level. - */ -public enum LoggerLevel { - - DEBUG, INFO, WARN, ERROR -} diff --git a/infra/common/src/test/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertiesTest.java b/infra/common/src/test/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertiesTest.java index 4e6b43621f947..3b88daf8adc73 100644 --- a/infra/common/src/test/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertiesTest.java +++ b/infra/common/src/test/java/org/apache/shardingsphere/infra/config/props/ConfigurationPropertiesTest.java @@ -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; @@ -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)); @@ -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"), @@ -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)); diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdaterTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdaterTest.java index e2c17c92dab99..1fb53f570b579 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdaterTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/SetDistVariableUpdaterTest.java @@ -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; @@ -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; @@ -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