test_class.declarator: log = new LogTelnetHandler()
test_class.modifier: private static
test_class.original_string: private static TelnetHandler log = new LogTelnetHandler();
test_class.type: TelnetHandler
test_class.var_name: log
test_class.declarator: mockChannel
test_class.modifier: private
test_class.original_string: private Channel mockChannel;
test_class.type: Channel
test_class.var_name: mockChannel
test_class.file: dubbo-rpc/dubbo-rpc-dubbo/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandlerTest.java
test_class.identifier: LogTelnetHandlerTest
test_case.body: @Test
      public void testChangeLogLevel() throws RemotingException {
          mockChannel = mock(Channel.class);
  
          String result = log.telnet(mockChannel, "error");
          assertTrue(result.contains("\r\nCURRENT LOG LEVEL:ERROR"));
          String result2 = log.telnet(mockChannel, "warn");
          assertTrue(result2.contains("\r\nCURRENT LOG LEVEL:WARN"));
      }
test_case.class_method_signature: LogTelnetHandlerTest.testChangeLogLevel()
test_case.full_signature: @Test public void testChangeLogLevel()
test_case.identifier: testChangeLogLevel
test_case.invocations: mock telnet assertTrue contains telnet assertTrue contains
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testChangeLogLevel()
focal_class.declarator: SERVICE_KEY = "telnet.log"
focal_class.modifier: public static final
focal_class.original_string: public static final String SERVICE_KEY = "telnet.log";
focal_class.type: String
focal_class.var_name: SERVICE_KEY
focal_class.file: dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/telnet/LogTelnetHandler.java
focal_class.identifier: LogTelnetHandler
focal_class.interfaces: implements TelnetHandler
focal_class.class_method_signature: LogTelnetHandler.telnet(Channel channel, String message)
focal_class.full_signature: @Override public String telnet(Channel channel, String message)
focal_class.identifier: telnet
focal_class.modifiers: @Override public
focal_class.parameters: (Channel channel, String message)
focal_class.return: String
focal_class.signature: String telnet(Channel channel, String message)
focal_method.body: @Override
      public String telnet(Channel channel, String message) {
          long size = 0;
          File file = LoggerFactory.getFile();
          StringBuffer buf = new StringBuffer();
          if (message == null || message.trim().length() == 0) {
              buf.append("EXAMPLE: log error / log 100");
          } else {
              String str[] = message.split(" ");
              if (!StringUtils.isInteger(str[0])) {
                  LoggerFactory.setLevel(Level.valueOf(message.toUpperCase()));
              } else {
                  int SHOW_LOG_LENGTH = Integer.parseInt(str[0]);
  
                  if (file != null && file.exists()) {
                      try {
                          FileInputStream fis = new FileInputStream(file);
                          FileChannel filechannel = fis.getChannel();
                          size = filechannel.size();
                          ByteBuffer bb;
                          if (size <= SHOW_LOG_LENGTH) {
                              bb = ByteBuffer.allocate((int) size);
                              filechannel.read(bb, 0);
                          } else {
                              int pos = (int) (size - SHOW_LOG_LENGTH);
                              bb = ByteBuffer.allocate(SHOW_LOG_LENGTH);
                              filechannel.read(bb, pos);
                          }
                          bb.flip();
                          String content = new String(bb.array()).replace("<", "&lt;")
                                  .replace(">", "&gt;").replace("\n", "<br/><br/>");
                          buf.append("\r\ncontent:" + content);
  
                          buf.append("\r\nmodified:" + (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
                                  .format(new Date(file.lastModified()))));
                          buf.append("\r\nsize:" + size + "\r\n");
                      } catch (Exception e) {
                          buf.append(e.getMessage());
                      }
                  } else {
                      size = 0;
                      buf.append("\r\nMESSAGE: log file not exists or log appender is console .");
                  }
              }
          }
          buf.append("\r\nCURRENT LOG LEVEL:" + LoggerFactory.getLevel())
                  .append("\r\nCURRENT LOG APPENDER:" + (file == null ? "console" : file.getAbsolutePath()));
          return buf.toString();
      }
focal_method.class_method_signature: LogTelnetHandler.telnet(Channel channel, String message)
focal_method.full_signature: @Override public String telnet(Channel channel, String message)
focal_method.identifier: telnet
focal_method.invocations: getFile length trim append split isInteger setLevel valueOf toUpperCase parseInt exists getChannel size allocate read allocate read flip replace replace replace array append append format lastModified append append getMessage append append append getLevel getAbsolutePath toString
focal_method.modifiers: @Override public
focal_method.parameters: (Channel channel, String message)
focal_method.return: String
focal_method.signature: String telnet(Channel channel, String message)