This is an automated email from the ASF dual-hosted git repository.
jianglongtao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 814379cb5dd Use jul instead of slf4j for log output in agent core
(#29746)
814379cb5dd is described below
commit 814379cb5dd0800c608aff5cd41637273bfaeff7
Author: jiangML <[email protected]>
AuthorDate: Wed Jan 17 15:59:06 2024 +0800
Use jul instead of slf4j for log output in agent core (#29746)
* Use jul instead of slf4j and logback log output
* Exclude slf4j when packaging
---
agent/core/pom.xml | 21 +++++++++
.../advisor/config/AdvisorConfigurationLoader.java | 7 ++-
.../executor/type/ConstructorAdviceExecutor.java | 9 ++--
.../type/InstanceMethodAdviceExecutor.java | 11 ++---
.../executor/type/StaticMethodAdviceExecutor.java | 11 ++---
.../agent/core/builder/AgentTransformer.java | 7 ++-
.../impl/MethodAdvisorBuilderInterceptor.java | 7 ++-
.../shardingsphere/agent/core/log/AgentLogger.java | 54 ---------------------
.../agent/core/log/AgentLoggerFactory.java | 55 ----------------------
.../agent/core/log/slf4j/SLF4JAgentLogger.java | 51 --------------------
.../core/plugin/PluginLifecycleServiceManager.java | 11 ++---
.../agent/core/plugin/jar/PluginJarLoader.java | 7 ++-
12 files changed, 52 insertions(+), 199 deletions(-)
diff --git a/agent/core/pom.xml b/agent/core/pom.xml
index 557beef9a07..d68e221e96d 100644
--- a/agent/core/pom.xml
+++ b/agent/core/pom.xml
@@ -58,6 +58,27 @@
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>com.cedarsoftware</groupId>
+ <artifactId>java-util</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jul-to-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/config/AdvisorConfigurationLoader.java
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/config/AdvisorConfigurationLoader.java
index ffcf9992505..1e0a3cc06e6 100644
---
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/config/AdvisorConfigurationLoader.java
+++
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/config/AdvisorConfigurationLoader.java
@@ -21,8 +21,6 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import
org.apache.shardingsphere.agent.core.advisor.config.yaml.loader.YamlAdvisorsConfigurationLoader;
import
org.apache.shardingsphere.agent.core.advisor.config.yaml.swapper.YamlAdvisorsConfigurationSwapper;
-import org.apache.shardingsphere.agent.core.log.AgentLogger;
-import org.apache.shardingsphere.agent.core.log.AgentLoggerFactory;
import
org.apache.shardingsphere.agent.core.plugin.classloader.AgentPluginClassLoader;
import java.io.File;
@@ -31,6 +29,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.jar.JarFile;
+import java.util.logging.Logger;
/**
* Advisor configuration loader.
@@ -38,7 +37,7 @@ import java.util.jar.JarFile;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class AdvisorConfigurationLoader {
- private static final AgentLogger LOGGER =
AgentLoggerFactory.getAgentLogger(AdvisorConfigurationLoader.class);
+ private static final Logger LOGGER =
Logger.getLogger(AdvisorConfigurationLoader.class.getName());
/**
* Load advisor configurations.
@@ -53,7 +52,7 @@ public final class AdvisorConfigurationLoader {
for (String each : pluginTypes) {
InputStream advisorsResourceStream =
getResourceStream(agentPluginClassLoader, each);
if (null == advisorsResourceStream) {
- LOGGER.info("No configuration of advisor for type `{}`.",
each);
+ LOGGER.info(String.format("No configuration of advisor for
type `%s`.", each));
} else {
mergeConfigurations(result,
YamlAdvisorsConfigurationSwapper.swap(YamlAdvisorsConfigurationLoader.load(advisorsResourceStream),
each));
}
diff --git
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/ConstructorAdviceExecutor.java
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/ConstructorAdviceExecutor.java
index 3d04236a2d0..ddfe7e65321 100644
---
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/ConstructorAdviceExecutor.java
+++
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/ConstructorAdviceExecutor.java
@@ -29,13 +29,12 @@ import net.bytebuddy.matcher.ElementMatchers;
import org.apache.shardingsphere.agent.api.advice.TargetAdviceObject;
import org.apache.shardingsphere.agent.api.advice.type.ConstructorAdvice;
import org.apache.shardingsphere.agent.core.advisor.executor.AdviceExecutor;
-import org.apache.shardingsphere.agent.core.log.AgentLogger;
-import org.apache.shardingsphere.agent.core.log.AgentLoggerFactory;
import org.apache.shardingsphere.agent.core.plugin.PluginContext;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.logging.Logger;
/**
* Constructor advice executor.
@@ -43,7 +42,7 @@ import java.util.Map.Entry;
@RequiredArgsConstructor
public final class ConstructorAdviceExecutor implements AdviceExecutor {
- private static final AgentLogger LOGGER =
AgentLoggerFactory.getAgentLogger(ConstructorAdviceExecutor.class);
+ private static final Logger LOGGER =
Logger.getLogger(ConstructorAdviceExecutor.class.getName());
private final Map<String, Collection<ConstructorAdvice>> advices;
@@ -66,9 +65,9 @@ public final class ConstructorAdviceExecutor implements
AdviceExecutor {
}
}
// CHECKSTYLE:OFF
- } catch (final Throwable throwable) {
+ } catch (final Throwable ex) {
// CHECKSTYLE:ON
- LOGGER.error("Constructor advice execution error. class: {}",
target.getClass().getTypeName(), throwable);
+ LOGGER.severe(String.format("Constructor advice execution error.
class: %s, %s", target.getClass().getTypeName(), ex.getMessage()));
}
}
diff --git
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/InstanceMethodAdviceExecutor.java
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/InstanceMethodAdviceExecutor.java
index 3c96d9d6591..e0d0156e386 100644
---
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/InstanceMethodAdviceExecutor.java
+++
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/InstanceMethodAdviceExecutor.java
@@ -31,8 +31,6 @@ import net.bytebuddy.matcher.ElementMatchers;
import org.apache.shardingsphere.agent.api.advice.TargetAdviceObject;
import org.apache.shardingsphere.agent.api.advice.type.InstanceMethodAdvice;
import org.apache.shardingsphere.agent.core.advisor.executor.AdviceExecutor;
-import org.apache.shardingsphere.agent.core.log.AgentLogger;
-import org.apache.shardingsphere.agent.core.log.AgentLoggerFactory;
import org.apache.shardingsphere.agent.core.plugin.PluginContext;
import java.lang.reflect.Method;
@@ -40,6 +38,7 @@ import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.Callable;
+import java.util.logging.Logger;
/**
* Instance method advice executor.
@@ -47,7 +46,7 @@ import java.util.concurrent.Callable;
@RequiredArgsConstructor
public final class InstanceMethodAdviceExecutor implements AdviceExecutor {
- private static final AgentLogger LOGGER =
AgentLoggerFactory.getAgentLogger(InstanceMethodAdviceExecutor.class);
+ private static final Logger LOGGER =
Logger.getLogger(InstanceMethodAdviceExecutor.class.getName());
private final Map<String, Collection<InstanceMethodAdvice>> advices;
@@ -95,7 +94,7 @@ public final class InstanceMethodAdviceExecutor implements
AdviceExecutor {
// CHECKSTYLE:OFF
} catch (final Throwable ex) {
// CHECKSTYLE:ON
- LOGGER.error("Failed to execute the pre-method of method `{}` in
class `{}`.", method.getName(), target.getClass(), ex);
+ LOGGER.severe(String.format("Failed to execute the pre-method of
method `%s` in class `%s`, %s.", method.getName(), target.getClass(),
ex.getMessage()));
}
}
@@ -109,7 +108,7 @@ public final class InstanceMethodAdviceExecutor implements
AdviceExecutor {
// CHECKSTYLE:OFF
} catch (final Throwable ignored) {
// CHECKSTYLE:ON
- LOGGER.error("Failed to execute the error handler of method `{}`
in class `{}`.", method.getName(), target.getClass(), ex);
+ LOGGER.severe(String.format("Failed to execute the error handler
of method `%s` in class `%s`, %s.", method.getName(), target.getClass(),
ex.getMessage()));
}
}
@@ -124,7 +123,7 @@ public final class InstanceMethodAdviceExecutor implements
AdviceExecutor {
// CHECKSTYLE:OFF
} catch (final Throwable ex) {
// CHECKSTYLE:ON
- LOGGER.error("Failed to execute the post-method of method `{}` in
class `{}`.", method.getName(), target.getClass(), ex);
+ LOGGER.severe(String.format("Failed to execute the post-method of
method `%s` in class `%s`, %s.", method.getName(), target.getClass(),
ex.getMessage()));
}
}
diff --git
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/StaticMethodAdviceExecutor.java
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/StaticMethodAdviceExecutor.java
index 82273a87614..2d681c338f3 100644
---
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/StaticMethodAdviceExecutor.java
+++
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/advisor/executor/type/StaticMethodAdviceExecutor.java
@@ -29,8 +29,6 @@ import net.bytebuddy.implementation.bind.annotation.SuperCall;
import net.bytebuddy.matcher.ElementMatchers;
import org.apache.shardingsphere.agent.api.advice.type.StaticMethodAdvice;
import org.apache.shardingsphere.agent.core.advisor.executor.AdviceExecutor;
-import org.apache.shardingsphere.agent.core.log.AgentLogger;
-import org.apache.shardingsphere.agent.core.log.AgentLoggerFactory;
import org.apache.shardingsphere.agent.core.plugin.PluginContext;
import java.lang.reflect.Method;
@@ -38,6 +36,7 @@ import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.Callable;
+import java.util.logging.Logger;
/**
* Static method advice executor.
@@ -45,7 +44,7 @@ import java.util.concurrent.Callable;
@RequiredArgsConstructor
public final class StaticMethodAdviceExecutor implements AdviceExecutor {
- private static final AgentLogger LOGGER =
AgentLoggerFactory.getAgentLogger(StaticMethodAdviceExecutor.class);
+ private static final Logger LOGGER =
Logger.getLogger(StaticMethodAdviceExecutor.class.getName());
private final Map<String, Collection<StaticMethodAdvice>> advices;
@@ -93,7 +92,7 @@ public final class StaticMethodAdviceExecutor implements
AdviceExecutor {
// CHECKSTYLE:OFF
} catch (final Throwable ex) {
// CHECKSTYLE:ON
- LOGGER.error("Failed to execute the pre-method of method `{}` in
class `{}`.", method.getName(), klass, ex);
+ LOGGER.severe(String.format("Failed to execute the pre-method of
method `%s` in class `%s`, %s.", method.getName(), klass, ex.getMessage()));
}
}
@@ -107,7 +106,7 @@ public final class StaticMethodAdviceExecutor implements
AdviceExecutor {
// CHECKSTYLE:OFF
} catch (final Throwable ignored) {
// CHECKSTYLE:ON
- LOGGER.error("Failed to execute the error handler of method `{}`
in class `{}`.", method.getName(), klass, ex);
+ LOGGER.severe(String.format("Failed to execute the error handler
of method `%s` in class `%s`, %s.", method.getName(), klass, ex.getMessage()));
}
}
@@ -121,7 +120,7 @@ public final class StaticMethodAdviceExecutor implements
AdviceExecutor {
// CHECKSTYLE:OFF
} catch (final Throwable ex) {
// CHECKSTYLE:ON
- LOGGER.error("Failed to execute the post-method of method `{}` in
class `{}`.", method.getName(), klass, ex);
+ LOGGER.severe(String.format("Failed to execute the post-method of
method `%s` in class `%s` %s.", method.getName(), klass, ex.getMessage()));
}
}
diff --git
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/builder/AgentTransformer.java
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/builder/AgentTransformer.java
index 04490481a10..bf64688cc93 100644
---
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/builder/AgentTransformer.java
+++
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/builder/AgentTransformer.java
@@ -31,8 +31,6 @@ import
org.apache.shardingsphere.agent.core.advisor.config.MethodAdvisorConfigur
import
org.apache.shardingsphere.agent.core.builder.interceptor.AgentBuilderInterceptChainEngine;
import
org.apache.shardingsphere.agent.core.builder.interceptor.impl.MethodAdvisorBuilderInterceptor;
import
org.apache.shardingsphere.agent.core.builder.interceptor.impl.TargetAdviceObjectBuilderInterceptor;
-import org.apache.shardingsphere.agent.core.log.AgentLogger;
-import org.apache.shardingsphere.agent.core.log.AgentLoggerFactory;
import
org.apache.shardingsphere.agent.core.plugin.PluginLifecycleServiceManager;
import
org.apache.shardingsphere.agent.core.plugin.classloader.AgentPluginClassLoader;
import
org.apache.shardingsphere.agent.core.plugin.classloader.ClassLoaderContext;
@@ -42,6 +40,7 @@ import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.jar.JarFile;
+import java.util.logging.Logger;
/**
* Agent transformer.
@@ -49,7 +48,7 @@ import java.util.jar.JarFile;
@RequiredArgsConstructor
public final class AgentTransformer implements Transformer {
- private static final AgentLogger LOGGER =
AgentLoggerFactory.getAgentLogger(AdvisorConfigurationLoader.class);
+ private static final Logger LOGGER =
Logger.getLogger(AdvisorConfigurationLoader.class.getName());
private static final Map<AgentPluginClassLoader, TypePool> TYPE_POOL_MAP =
new ConcurrentHashMap<>();
@@ -80,7 +79,7 @@ public final class AgentTransformer implements Transformer {
result.getAdvisors().add(each);
continue;
}
- LOGGER.error("The advice class `{}` does not exist",
each.getAdviceClassName());
+ LOGGER.severe(String.format("The advice class `%s` does not
exist", each.getAdviceClassName()));
}
return result;
}
diff --git
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/builder/interceptor/impl/MethodAdvisorBuilderInterceptor.java
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/builder/interceptor/impl/MethodAdvisorBuilderInterceptor.java
index c9f1d5b5e16..fa998efee32 100644
---
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/builder/interceptor/impl/MethodAdvisorBuilderInterceptor.java
+++
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/builder/interceptor/impl/MethodAdvisorBuilderInterceptor.java
@@ -25,17 +25,16 @@ import
org.apache.shardingsphere.agent.core.advisor.executor.AdviceExecutor;
import
org.apache.shardingsphere.agent.core.advisor.executor.AdviceExecutorFactory;
import
org.apache.shardingsphere.agent.core.builder.interceptor.AgentBuilderInterceptor;
import
org.apache.shardingsphere.agent.core.plugin.classloader.ClassLoaderContext;
-import org.apache.shardingsphere.agent.core.log.AgentLogger;
-import org.apache.shardingsphere.agent.core.log.AgentLoggerFactory;
import java.util.Optional;
+import java.util.logging.Logger;
/**
* Method advisor builder interceptor.
*/
public final class MethodAdvisorBuilderInterceptor implements
AgentBuilderInterceptor {
- private static final AgentLogger LOGGER =
AgentLoggerFactory.getAgentLogger(MethodAdvisorBuilderInterceptor.class);
+ private static final Logger LOGGER =
Logger.getLogger(MethodAdvisorBuilderInterceptor.class.getName());
private final TypeDescription typePointcut;
@@ -59,7 +58,7 @@ public final class MethodAdvisorBuilderInterceptor implements
AgentBuilderInterc
// CHECKSTYLE:OFF
} catch (final Throwable ex) {
// CHECKSTYLE:ON
- LOGGER.error("Failed to load advice class: {}.",
typePointcut.getTypeName(), ex);
+ LOGGER.severe(String.format("Failed to load advice class: %s,
%s.", typePointcut.getTypeName(), ex.getMessage()));
}
}
return result;
diff --git
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/log/AgentLogger.java
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/log/AgentLogger.java
deleted file mode 100644
index 4f69ca1b3a5..00000000000
---
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/log/AgentLogger.java
+++ /dev/null
@@ -1,54 +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.agent.core.log;
-
-/**
- * Agent logger.
- */
-public interface AgentLogger {
-
- /**
- * Info.
- *
- * @param msg message
- */
- void info(String msg);
-
- /**
- * Info.
- *
- * @param format format
- * @param arguments arguments
- */
- void info(String format, Object... arguments);
-
- /**
- * Error.
- *
- * @param format format
- * @param arguments arguments
- */
- void error(String format, Object... arguments);
-
- /**
- * Error.
- *
- * @param msg message
- */
- void error(String msg);
-}
diff --git
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/log/AgentLoggerFactory.java
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/log/AgentLoggerFactory.java
deleted file mode 100644
index b80206195d0..00000000000
---
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/log/AgentLoggerFactory.java
+++ /dev/null
@@ -1,55 +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.agent.core.log;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.agent.core.log.slf4j.SLF4JAgentLogger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Agent logger factory.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class AgentLoggerFactory {
-
- private static final Map<String, AgentLogger> LOGGERS = new
ConcurrentHashMap<>();
-
- /**
- * Get agent logger.
- *
- * @param clazz clazz
- * @return agent logger
- */
- public static AgentLogger getAgentLogger(final Class<?> clazz) {
- return AgentLoggerFactory.getAgentLogger(clazz.getName());
- }
-
- /**
- * Get agent logger.
- *
- * @param name name
- * @return agent logger
- */
- public static AgentLogger getAgentLogger(final String name) {
- return LOGGERS.computeIfAbsent(name, key -> new
SLF4JAgentLogger(LoggerFactory.getLogger(name)));
- }
-}
diff --git
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/log/slf4j/SLF4JAgentLogger.java
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/log/slf4j/SLF4JAgentLogger.java
deleted file mode 100644
index 656d23ff1ae..00000000000
---
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/log/slf4j/SLF4JAgentLogger.java
+++ /dev/null
@@ -1,51 +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.agent.core.log.slf4j;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.agent.core.log.AgentLogger;
-import org.slf4j.Logger;
-
-/**
- * SLF4J agent logger.
- */
-@RequiredArgsConstructor
-public final class SLF4JAgentLogger implements AgentLogger {
-
- private final Logger logger;
-
- @Override
- public void info(final String msg) {
- logger.info(msg);
- }
-
- @Override
- public void info(final String format, final Object... arguments) {
- logger.info(format, arguments);
- }
-
- @Override
- public void error(final String format, final Object... arguments) {
- logger.error(format, arguments);
- }
-
- @Override
- public void error(final String msg) {
- logger.error(msg);
- }
-}
diff --git
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginLifecycleServiceManager.java
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginLifecycleServiceManager.java
index cba79223764..c36f5bbc050 100644
---
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginLifecycleServiceManager.java
+++
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginLifecycleServiceManager.java
@@ -20,8 +20,6 @@ package org.apache.shardingsphere.agent.core.plugin;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.agent.api.PluginConfiguration;
-import org.apache.shardingsphere.agent.core.log.AgentLogger;
-import org.apache.shardingsphere.agent.core.log.AgentLoggerFactory;
import org.apache.shardingsphere.agent.core.spi.AgentServiceLoader;
import org.apache.shardingsphere.agent.spi.PluginLifecycleService;
@@ -31,6 +29,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.jar.JarFile;
+import java.util.logging.Logger;
/**
* Plugin lifecycle service manager.
@@ -40,7 +39,7 @@ public final class PluginLifecycleServiceManager {
private static final AtomicBoolean STARTED_FLAG = new AtomicBoolean(false);
- private static final AgentLogger LOGGER =
AgentLoggerFactory.getAgentLogger(PluginLifecycleServiceManager.class);
+ private static final Logger LOGGER =
Logger.getLogger(PluginLifecycleServiceManager.class.getName());
/**
* Initialize all plugins.
@@ -72,12 +71,12 @@ public final class PluginLifecycleServiceManager {
private static void start(final PluginConfiguration pluginConfig, final
PluginLifecycleService pluginLifecycleService, final boolean
isEnhancedForProxy) {
try {
- LOGGER.info("Start plugin: {}", pluginLifecycleService.getType());
+ LOGGER.info(String.format("Start plugin: %s",
pluginLifecycleService.getType()));
pluginLifecycleService.start(pluginConfig, isEnhancedForProxy);
// CHECKSTYLE:OFF
} catch (final Throwable ex) {
// CHECKSTYLE:ON
- LOGGER.error("Failed to start service.", ex);
+ LOGGER.severe(String.format("Failed to start service %s.",
ex.getMessage()));
}
}
@@ -87,7 +86,7 @@ public final class PluginLifecycleServiceManager {
try {
each.close();
} catch (final IOException ex) {
- LOGGER.error("Failed to close jar file.", ex);
+ LOGGER.severe(String.format("Failed to close jar file %s.",
ex.getMessage()));
}
});
}
diff --git
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/jar/PluginJarLoader.java
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/jar/PluginJarLoader.java
index bb61a6a27c3..530752bc79c 100644
---
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/jar/PluginJarLoader.java
+++
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/plugin/jar/PluginJarLoader.java
@@ -20,8 +20,6 @@ package org.apache.shardingsphere.agent.core.plugin.jar;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
-import org.apache.shardingsphere.agent.core.log.AgentLogger;
-import org.apache.shardingsphere.agent.core.log.AgentLoggerFactory;
import java.io.File;
import java.io.IOException;
@@ -33,6 +31,7 @@ import java.nio.file.attribute.BasicFileAttributes;
import java.util.Collection;
import java.util.LinkedList;
import java.util.jar.JarFile;
+import java.util.logging.Logger;
/**
* Plugin jar loader.
@@ -40,7 +39,7 @@ import java.util.jar.JarFile;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class PluginJarLoader {
- private static final AgentLogger LOGGER =
AgentLoggerFactory.getAgentLogger(PluginJarLoader.class);
+ private static final Logger LOGGER =
Logger.getLogger(PluginJarLoader.class.getName());
/**
* Load plugin jars.
@@ -54,7 +53,7 @@ public final class PluginJarLoader {
Collection<JarFile> result = new LinkedList<>();
for (File each : jarFiles) {
result.add(new JarFile(each, true));
- LOGGER.info("Loaded jar: {}", each.getName());
+ LOGGER.info(String.format("Loaded jar: %s", each.getName()));
}
return result;
}