Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replaced log4j dependency with SLF4J

SLF4J is a better dependency for code used in potentially many 
projects, as it doesn't couple a specific logging dependency to 
the shared code.
  • Loading branch information...
commit d54b9c069aefc74af24756495c74f5baee7c79a0 1 parent 5176831
fragnemesis authored
Showing with 4 additions and 32 deletions.
  1. +4 −32 Expect.java
36 Expect.java
View
@@ -12,12 +12,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.FileAppender;
-import org.apache.log4j.Layout;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -45,11 +41,7 @@
* @version 1.1
*/
public class Expect {
- static final Logger log = Logger.getLogger(Expect.class);
- /**Logging is turned off by default.*/
- static {
- log.setLevel(Level.OFF);
- }
+ private static final Logger log = LoggerFactory.getLogger(Expect.class);
private OutputStream output;
private Pipe.SourceChannel inputChannel;
@@ -62,7 +54,7 @@ public Expect(InputStream input, OutputStream output) {
selector = Selector.open();
inputChannel.register(selector, SelectionKey.OP_READ);
} catch (IOException e) {
- log.fatal("Fatal error when initializing pipe or selector", e);
+ log.error("Fatal error when initializing pipe or selector", e);
//e.printStackTrace();
}
this.output = output;
@@ -496,26 +488,6 @@ public static String byteToPrintableString(byte b) {
public static class EOFException extends Exception{
}
- private static Layout layout = new PatternLayout(
- PatternLayout.TTCC_CONVERSION_PATTERN);
-
- public static void addLogToConsole(Level level) {
- log.setLevel(Level.ALL);
- ConsoleAppender console = new ConsoleAppender(layout);
- console.setThreshold(level);
- log.addAppender(console);
- }
- public static void addLogToFile(String filename, Level level) throws IOException {
- log.setLevel(Level.ALL);
- FileAppender file = new FileAppender(layout, filename);
- file.setThreshold(level);
- log.addAppender(file);
- }
- public static void turnOffLogging(){
- log.setLevel(Level.OFF);
- log.removeAllAppenders();
- }
-
private static PrintStream duplicatedTo = null;
/**
* While performing expect operations on the InputStream provided, duplicate
Please sign in to comment.
Something went wrong with that request. Please try again.