huangwenkan9 commented on a change in pull request #9052:
URL: https://github.com/apache/dubbo/pull/9052#discussion_r756114617



##########
File path: 
dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/jetty/JettyLoggerAdapter.java
##########
@@ -0,0 +1,159 @@
+/*
+ * 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.dubbo.remoting.http.jetty;
+
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.eclipse.jetty.util.log.AbstractLogger;
+import org.eclipse.jetty.util.log.Logger;
+
+/**
+ * logger adapter for jetty
+ */
+public class JettyLoggerAdapter extends AbstractLogger {
+    protected String name;
+    private final org.apache.dubbo.common.logger.Logger logger;
+
+    public JettyLoggerAdapter(){
+        this("org.apache.dubbo.remoting.http.jetty");
+    }
+
+    public JettyLoggerAdapter(Class<?> clazz){
+        this(clazz.getName());
+    }
+
+    public JettyLoggerAdapter(String name) {
+        this.name = name;
+        this.logger = LoggerFactory.getLogger(name);
+    }
+
+    @Override
+    protected Logger newLogger(String name) {
+        return new JettyLoggerAdapter(name);
+    }
+
+    @Override
+    public String getName() {
+        return this.name;
+    }
+
+    @Override
+    public void warn(String msg, Object... objects) {
+        if (logger.isWarnEnabled()){
+            logger.warn(this.format(msg, objects));
+        }
+    }
+
+    @Override
+    public void warn(Throwable throwable) {
+        if (logger.isWarnEnabled()){
+            logger.warn(throwable);
+        }
+    }
+
+    @Override
+    public void warn(String msg, Throwable throwable) {
+        if (logger.isWarnEnabled()){
+            logger.warn(msg, throwable);
+        }
+    }
+
+    @Override
+    public void info(String msg, Object... objects) {
+        if (logger.isInfoEnabled()){
+            logger.info(this.format(msg, objects));
+        }
+    }
+
+    @Override
+    public void info(Throwable throwable) {
+        if (logger.isInfoEnabled()){
+            logger.info(throwable);
+        }
+    }
+
+    @Override
+    public void info(String msg, Throwable throwable) {
+        if (logger.isInfoEnabled()){
+            logger.info(msg, throwable);
+        }
+    }
+
+    @Override
+    public boolean isDebugEnabled() {
+        return logger.isDebugEnabled();
+    }
+
+    @Override
+    public void setDebugEnabled(boolean enabled) {
+        logger.warn("setDebugEnabled not implemented");
+    }
+
+    @Override
+    public void debug(String msg, Object... objects) {
+        if (logger.isDebugEnabled()){
+            logger.debug(this.format(msg, objects));
+        }
+    }
+
+    @Override
+    public void debug(Throwable throwable) {
+        if (logger.isDebugEnabled()){
+            logger.debug(throwable);
+        }
+    }
+
+    @Override
+    public void debug(String msg, Throwable throwable) {
+        if (logger.isDebugEnabled()){
+            logger.debug(msg, throwable);
+        }
+    }
+
+    @Override
+    public void ignore(Throwable throwable) {
+        if (logger.isDebugEnabled()){
+            logger.debug("IGNORED EXCEPTION ", throwable);
+        }
+    }
+
+    private String format(String msg, Object... args) {

Review comment:
       how to test private method using mockito




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to