From 99d155e0fe8f46953d584ee105c0438db5a29965 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Tue, 8 Mar 2011 17:48:03 +0000 Subject: [PATCH] Control API logging using the bitcoinj.logging global property. --- src/com/google/bitcoin/core/Utils.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/com/google/bitcoin/core/Utils.java b/src/com/google/bitcoin/core/Utils.java index 8b771788..eb90888c 100644 --- a/src/com/google/bitcoin/core/Utils.java +++ b/src/com/google/bitcoin/core/Utils.java @@ -26,6 +26,7 @@ import java.security.NoSuchAlgorithmException; /** * A collection of various utility methods that are helpful for working with the BitCoin protocol. + * To enable debug logging from the library, run with -Dbitcoinj.logging=true on your command line. */ public class Utils { /** How many nanocoins there are in a BitCoin. */ @@ -33,6 +34,12 @@ public class Utils { /** How many nanocoins there are in 0.01 BitCoins. */ public static final BigInteger CENT = new BigInteger("1000000", 10); + private static boolean logging; + + static { + logging = Boolean.parseBoolean(System.getProperty("bitcoinj.logging", "false")); + } + /** Convert an amount expressed in the way humans are used to into nanocoins. */ public static BigInteger toNanoCoins(int coins, int cents) { assert cents < 100; @@ -159,7 +166,7 @@ public class Utils { static void LOG(String msg) { // Set this to true to see debug prints from the library. - if (false) { + if (logging) { System.out.print("BitCoin: "); System.out.println(msg); }