Skip to content

Commit a638f35

Browse files
Knut Anders Hatlentrondn
authored andcommitted
Bug #15391: Executor should log the commands executed
1 parent d3f4f9e commit a638f35

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/org/opensolaris/opengrok/util/Executor.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
* CDDL HEADER END
1818
*/
1919

20+
/*
21+
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
22+
* Use is subject to license terms.
23+
*/
24+
2025
package org.opensolaris.opengrok.util;
2126

2227
import java.io.ByteArrayInputStream;
@@ -114,6 +119,13 @@ public int exec(final boolean reportExceptions, StreamHandler handler) {
114119
}
115120
}
116121

122+
OpenGrokLogger.getLogger().log(Level.FINE,
123+
"Executing command {0} in directory {1}",
124+
new Object[] {
125+
processBuilder.command(),
126+
processBuilder.directory(),
127+
});
128+
117129
Process process = null;
118130
try {
119131
process = processBuilder.start();
@@ -162,6 +174,15 @@ public void run() {
162174
}
163175
}
164176

177+
if (ret != 0) {
178+
OpenGrokLogger.getLogger().log(
179+
reportExceptions ? Level.SEVERE : Level.FINE,
180+
"Non-zero exit status {0} from command {1} in directory {2}",
181+
new Object[] {
182+
ret, processBuilder.command(), processBuilder.directory()
183+
});
184+
}
185+
165186
return ret;
166187
}
167188

0 commit comments

Comments
 (0)