diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2015-02-09 21:54:58 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2015-02-17 01:06:17 +0100 |
commit | c18694e0d1c122a2f95537fd9254fb075d2e0bc2 (patch) | |
tree | 2da7e6a8382e68ae88a334d28f61d79a15536852 /org.eclipse.jgit/src/org/eclipse/jgit/util | |
parent | af4bde1ed257c9f0311fc31e14c2f3087ea8e928 (diff) | |
download | jgit-c18694e0d1c122a2f95537fd9254fb075d2e0bc2.tar.gz jgit-c18694e0d1c122a2f95537fd9254fb075d2e0bc2.zip |
Use slf4j to log instead of printing to System.err
CQ: 9206
Bug: 458445
Change-Id: Ic68fb7dbe0fb46bf30f157db45bf18d8f3a704c0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/util')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index 081bf87c54..875e12f57b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -69,6 +69,8 @@ import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.util.ProcessResult.Status; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Abstraction to support various file system operations not in Java. */ public abstract class FS { @@ -107,6 +109,8 @@ public abstract class FS { } } + private final static Logger LOG = LoggerFactory.getLogger(FS.class); + /** The auto-detected implementation selected for this operating system and JRE. */ public static final FS DETECTED = detect(); @@ -418,12 +422,12 @@ public abstract class FS { * @return the one-line output of the command */ protected static String readPipe(File dir, String[] command, String encoding) { - final boolean debug = Boolean.parseBoolean(SystemReader.getInstance() - .getProperty("jgit.fs.debug")); //$NON-NLS-1$ + final boolean debug = LOG.isDebugEnabled(); try { - if (debug) - System.err.println("readpipe " + Arrays.asList(command) + "," //$NON-NLS-1$ //$NON-NLS-2$ + if (debug) { + LOG.debug("readpipe " + Arrays.asList(command) + "," //$NON-NLS-1$ //$NON-NLS-2$ + dir); + } final Process p = Runtime.getRuntime().exec(command, null, dir); final BufferedReader lineRead = new BufferedReader( new InputStreamReader(p.getInputStream(), encoding)); @@ -451,8 +455,9 @@ public abstract class FS { is.close(); } catch (IOException e) { // Just print on stderr for debugging - if (debug) - e.printStackTrace(System.err); + if (debug) { + LOG.debug("Caught exception in gobbler thread", e); //$NON-NLS-1$ + } gooblerFail.set(true); } } @@ -462,13 +467,14 @@ public abstract class FS { try { r = lineRead.readLine(); if (debug) { - System.err.println("readpipe may return '" + r + "'"); //$NON-NLS-1$ //$NON-NLS-2$ - System.err.println("(ignoring remaing output:"); //$NON-NLS-1$ + LOG.debug("readpipe may return '" + r + "'"); //$NON-NLS-1$ //$NON-NLS-2$ + LOG.debug("(ignoring remaing output:"); //$NON-NLS-1$ } String l; while ((l = lineRead.readLine()) != null) { - if (debug) - System.err.println(l); + if (debug) { + LOG.debug(l); + } } } finally { p.getErrorStream().close(); @@ -482,20 +488,20 @@ public abstract class FS { if (rc == 0 && r != null && r.length() > 0 && !gooblerFail.get()) return r; - if (debug) - System.err.println("readpipe rc=" + rc); //$NON-NLS-1$ + if (debug) { + LOG.debug("readpipe rc=" + rc); //$NON-NLS-1$ + } break; } catch (InterruptedException ie) { // Stop bothering me, I have a zombie to reap. } } } catch (IOException e) { - if (debug) - System.err.println(e); - // Ignore error (but report) + LOG.error("Caught exception in FS.readPipe()", e); //$NON-NLS-1$ + } + if (debug) { + LOG.debug("readpipe returns null"); //$NON-NLS-1$ } - if (debug) - System.err.println("readpipe returns null"); //$NON-NLS-1$ return null; } |