View Javadoc
1   package edu.jiangxin.apktoolbox.utils;
2   
3   import org.apache.commons.exec.LogOutputStream;
4   import org.apache.logging.log4j.Level;
5   import org.apache.logging.log4j.Logger;
6   
7   /**
8    * Record output or errput of child process to Apache logging system
9    */
10  public class ProcessLogOutputStream extends LogOutputStream {
11      Logger logger;
12      Level level;
13  
14      public ProcessLogOutputStream(Logger logger, Level level) {
15          this.logger = logger;
16          this.level = level;
17      }
18  
19      @Override
20      protected void processLine(String line, int logLevel) {
21          logger.log(level, "[" + line + "]");
22      }
23  }