Improved: Logging: change all System.out/.err/.. println to Debug.log... in the code base (OFBIZ-10045)
Thanks Michael Brohl and Kyra Pritzel-Hentley for your contribution git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1819124 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -19,20 +19,23 @@
|
||||
package org.apache.ofbiz.base.crypto;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.ofbiz.base.util.Debug;
|
||||
import org.apache.shiro.crypto.AesCipherService;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static final String module = Main.class.getName();
|
||||
public static void main(String[] args) throws Exception {
|
||||
if ("-crypt".equals(args[0])) {
|
||||
System.out.println(HashCrypt.cryptUTF8(args[1], null, args[2]));
|
||||
Debug.logInfo(HashCrypt.cryptUTF8(args[1], null, args[2]), module);
|
||||
} else if ("-digest".equals(args[0])) {
|
||||
String digest = HashCrypt.digestHash("SHA", null, args[1]);
|
||||
System.out.println(digest);
|
||||
Debug.logInfo(digest, module);
|
||||
} else if ("-kek".equals(args[0])) {
|
||||
AesCipherService cs = new AesCipherService();
|
||||
System.out.println(Base64.encodeBase64String(cs.generateNewKey().getEncoded()));
|
||||
Debug.logInfo(Base64.encodeBase64String(cs.generateNewKey().getEncoded()), module);
|
||||
} else if ("-kek-old".equals(args[0])) {
|
||||
System.out.println(Base64.encodeBase64String(DesCrypt.generateKey().getEncoded()));
|
||||
Debug.logInfo(Base64.encodeBase64String(DesCrypt.generateKey().getEncoded()), module);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.ofbiz.base.util.Debug;
|
||||
import org.apache.ofbiz.base.util.UtilProperties;
|
||||
import org.apache.ofbiz.base.util.UtilValidate;
|
||||
|
||||
@@ -35,6 +36,7 @@ import org.apache.ofbiz.base.util.UtilValidate;
|
||||
*/
|
||||
public final class FlexibleLocation {
|
||||
|
||||
public static final String module = FlexibleLocation.class.getName();
|
||||
private static final Map<String, LocationResolver> locationResolvers;
|
||||
|
||||
static {
|
||||
@@ -64,7 +66,7 @@ public final class FlexibleLocation {
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
System.out.println("Exception thrown while loading locationresolvers.properties: " + e);
|
||||
Debug.logError(e, "Exception thrown while loading locationresolvers.properties", module);
|
||||
}
|
||||
locationResolvers = Collections.unmodifiableMap(resolverMap);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public class HttpRequestFileUpload {
|
||||
|
||||
String reqLengthString = request.getHeader("content-length");
|
||||
|
||||
System.out.println("expect " + reqLengthString + " bytes.");
|
||||
Debug.logInfo("expect " + reqLengthString + " bytes.", module);
|
||||
int requestLength = 0;
|
||||
|
||||
try {
|
||||
@@ -139,7 +139,7 @@ public class HttpRequestFileUpload {
|
||||
|
||||
String boundary = new String(line, 0, boundaryLength, UtilIO.getUtf8()); // -2 discards the newline character
|
||||
|
||||
System.out.println("boundary=[" + boundary + "] length is " + boundaryLength);
|
||||
Debug.logInfo("boundary=[" + boundary + "] length is " + boundaryLength, module);
|
||||
fields = new HashMap<>();
|
||||
|
||||
while (requestLength > 0/* i != -1*/) {
|
||||
@@ -178,7 +178,7 @@ public class HttpRequestFileUpload {
|
||||
lastTwoBytes[0] = line[i - 2];
|
||||
lastTwoBytes[1] = line[i - 1];
|
||||
}
|
||||
System.out.println("about to create a file:" + (savePath == null ? "" : savePath) + filenameToUse);
|
||||
Debug.logInfo("about to create a file:" + (savePath == null ? "" : savePath) + filenameToUse, module);
|
||||
// before creating the file make sure directory exists
|
||||
if (savePath == null) {
|
||||
throw new IllegalArgumentException("savePath is null");
|
||||
@@ -282,10 +282,10 @@ public class HttpRequestFileUpload {
|
||||
int i = -1;
|
||||
|
||||
while (((i = in.readLine(buf, off, len)) == -1) && (reqLen > 0)) {
|
||||
System.out.print("waiting");
|
||||
Debug.logInfo("waiting", module);
|
||||
if (waitCount > MAX_WAITS) {
|
||||
System.out.println("waited " + waitCount + " times, bailing out while still expecting " +
|
||||
reqLen + " bytes.");
|
||||
Debug.logInfo("waited " + waitCount + " times, bailing out while still expecting " +
|
||||
reqLen + " bytes.", module);
|
||||
throw new IOException("waited " + waitCount + " times, bailing out while still expecting " +
|
||||
reqLen + " bytes.");
|
||||
}
|
||||
@@ -296,10 +296,10 @@ public class HttpRequestFileUpload {
|
||||
try {
|
||||
wait(WAIT_INTERVAL);
|
||||
} catch (Exception e3) {
|
||||
System.out.print(".");
|
||||
Debug.logInfo(".", module);
|
||||
}
|
||||
}
|
||||
System.out.println((new Date().getTime() - endMS) + " ms");
|
||||
Debug.logInfo((new Date().getTime() - endMS) + " ms", module);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ public final class UtilProperties implements Serializable {
|
||||
try {
|
||||
inStream.close();
|
||||
} catch (IOException e) {
|
||||
System.out.println("Exception thrown while closing InputStream: " + e);
|
||||
Debug.logError(e, "Exception thrown while closing InputStream", module);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-10
@@ -25,11 +25,15 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ofbiz.base.test.GenericTestCaseBase;
|
||||
import org.apache.ofbiz.base.util.Debug;
|
||||
import org.apache.ofbiz.base.util.collections.GenericMap;
|
||||
import org.apache.ofbiz.base.util.collections.GenericMapEntry;
|
||||
import org.apache.ofbiz.base.util.collections.IteratorWrapper;
|
||||
|
||||
public class GenericMapTest extends GenericTestCaseBase {
|
||||
|
||||
public static final String module = GenericMapTest.class.getName();
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class TestGenericMap<K, V> extends GenericMap<K, V> {
|
||||
private static final String[] countNames = {
|
||||
@@ -147,24 +151,24 @@ public class GenericMapTest extends GenericTestCaseBase {
|
||||
|
||||
public void testFoo() throws Exception {
|
||||
TestGenericMap<String, Integer> map = new TestGenericMap<String, Integer>();
|
||||
map.put("a", 0); System.err.println("put a\t\tcounts=" + map.getCounts() + ", modCount=" + map.getModCount());
|
||||
map.put("a", 0); Debug.logInfo("put a\t\tcounts=" + map.getCounts() + ", modCount=" + map.getModCount(), module);
|
||||
assertEquals("get a", Integer.valueOf(0), map.get("a"));
|
||||
map.put("b", 1); System.err.println("put b\t\tcounts=" + map.getCounts() + ", modCount=" + map.getModCount());
|
||||
map.put("b", 1); Debug.logInfo("put b\t\tcounts=" + map.getCounts() + ", modCount=" + map.getModCount(), module);
|
||||
assertEquals("get b", Integer.valueOf(1), map.get("b"));
|
||||
map.put("c", 2); System.err.println("put c\t\tcounts=" + map.getCounts() + ", modCount=" + map.getModCount());
|
||||
map.put("c", 2); Debug.logInfo("put c\t\tcounts=" + map.getCounts() + ", modCount=" + map.getModCount(), module);
|
||||
assertEquals("get c", Integer.valueOf(2), map.get("c"));
|
||||
map.put("d", 3); System.err.println("put d\t\tcounts=" + map.getCounts() + ", modCount=" + map.getModCount());
|
||||
map.put("d", 3); Debug.logInfo("put d\t\tcounts=" + map.getCounts() + ", modCount=" + map.getModCount(), module);
|
||||
assertEquals("get d", Integer.valueOf(3), map.get("d"));
|
||||
map.put("c", 22); System.err.println("put c-2\t\tcounts=" + map.getCounts() + ", modCount=" + map.getModCount());
|
||||
map.put("c", 22); Debug.logInfo("put c-2\t\tcounts=" + map.getCounts() + ", modCount=" + map.getModCount(), module);
|
||||
assertEquals("get c-2", Integer.valueOf(22), map.get("c"));
|
||||
map.remove("b"); System.err.println("remove b\tcounts=" + map.getCounts() + ", modCount=" + map.getModCount());
|
||||
map.remove("b"); Debug.logInfo("remove b\tcounts=" + map.getCounts() + ", modCount=" + map.getModCount(), module);
|
||||
assertNull("null b", map.get("b"));
|
||||
map.remove("aaa"); System.err.println("remove aaa\tcounts=" + map.getCounts() + ", modCount=" + map.getModCount());
|
||||
System.err.println("map=" + map);
|
||||
System.err.println("counts=" + map.getCounts() + ", modCount=" + map.getModCount());
|
||||
map.remove("aaa"); Debug.logInfo("remove aaa\tcounts=" + map.getCounts() + ", modCount=" + map.getModCount(), module);
|
||||
Debug.logInfo("map=" + map, module);
|
||||
Debug.logInfo("counts=" + map.getCounts() + ", modCount=" + map.getModCount(), module);
|
||||
// this seems to call size()
|
||||
new HashMap<String, Integer>(map);
|
||||
System.err.println("counts=" + map.getCounts() + ", modCount=" + map.getModCount());
|
||||
Debug.logInfo("counts=" + map.getCounts() + ", modCount=" + map.getModCount(), module);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user