lindzh commented on a change in pull request #221: [ROCKETMQ-359] Replace slf4j 
api used in RocketMQ with InternalLogger
URL: https://github.com/apache/rocketmq/pull/221#discussion_r171825186
 
 

 ##########
 File path: 
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyLogger.java
 ##########
 @@ -0,0 +1,316 @@
+/*
+ * 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.rocketmq.remoting.netty;
+
+
+import io.netty.util.internal.logging.InternalLogLevel;
+import org.apache.rocketmq.logging.InternalLogger;
+import org.apache.rocketmq.logging.InternalLoggerFactory;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public class NettyLogger {
+
+    private static AtomicBoolean nettyLoggerSeted = new AtomicBoolean(false);
+    
+    private static InternalLogLevel nettyLogLevel = InternalLogLevel.ERROR;
+
+    public static void initNettyLogger() {
+        if (!nettyLoggerSeted.get()) {
+            try {
+                
io.netty.util.internal.logging.InternalLoggerFactory.setDefaultFactory(new 
NettyBridgeLoggerFactory());
+            } catch (Throwable e) {
+                //ignore
+            }
+            nettyLoggerSeted.set(true);
+        }
+    }
+
+    private static class NettyBridgeLoggerFactory extends 
io.netty.util.internal.logging.InternalLoggerFactory {
+        @Override
+        protected io.netty.util.internal.logging.InternalLogger 
newInstance(String s) {
+            return new NettyBridgeLogger(s);
+        }
+    }
+
+    private static class NettyBridgeLogger implements 
io.netty.util.internal.logging.InternalLogger {
+
+        private InternalLogger logger = null;
+
+        public NettyBridgeLogger(String name) {
+            logger = InternalLoggerFactory.getLogger(name);
+        }
+
+        @Override
+        public String name() {
+            return logger.getName();
+        }
+
+        // FIXME: 2018/3/2 
 
 Review comment:
   Fixme has been deleted.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to