From aec1b3aeef9981e58771b05821baa9df164b7889 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Sat, 26 Jun 2010 04:03:33 +0000 Subject: [PATCH] * jbigi, jcpuid: Suppress log messages when not in router context --- .../src/freenet/support/CPUInformation/CPUID.java | 14 +++++++++++--- core/java/src/net/i2p/util/NativeBigInteger.java | 11 ++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/core/java/src/freenet/support/CPUInformation/CPUID.java b/core/java/src/freenet/support/CPUInformation/CPUID.java index e89fa80d26..83aa333670 100644 --- a/core/java/src/freenet/support/CPUInformation/CPUID.java +++ b/core/java/src/freenet/support/CPUInformation/CPUID.java @@ -34,8 +34,15 @@ public class CPUID { * do we want to dump some basic success/failure info to stderr during * initialization? this would otherwise use the Log component, but this makes * it easier for other systems to reuse this class + * + * Well, we really want to use Log so if you are one of those "other systems" + * then comment out the I2PAppContext usage below. + * + * Set to false if not in router context, so scripts using TrustedUpdate + * don't spew log messages. main() below overrides to true. */ - private static final boolean _doLog = System.getProperty("jcpuid.dontLog") == null; + private static boolean _doLog = System.getProperty("jcpuid.dontLog") == null && + I2PAppContext.getGlobalContext().isRouterContext(); //.matches() is a java 1.4+ addition, using a simplified version for 1.3+ //private static final boolean isX86 = System.getProperty("os.arch").toLowerCase().matches("i?[x0-9]86(_64)?"); @@ -391,6 +398,7 @@ public class CPUID { public static void main(String args[]) { + _doLog = true; if(!_nativeOk){ System.out.println("**Failed to retrieve CPUInfo. Please verify the existence of jcpuid dll/so**"); } @@ -446,7 +454,7 @@ public class CPUID { } else { _nativeOk = false; if (_doLog) - System.err.println("WARN: Native CPUID library jcpuid not loaded - will not be able to read CPU information using CPUID"); + System.err.println("WARNING: Native CPUID library jcpuid not loaded - will not be able to read CPU information using CPUID"); } } } else { @@ -502,7 +510,7 @@ public class CPUID { if (resource == null) { if (_doLog) - System.err.println("ERROR: Resource name [" + resourceName + "] was not found"); + System.err.println("WARNING: Resource name [" + resourceName + "] was not found"); return false; } diff --git a/core/java/src/net/i2p/util/NativeBigInteger.java b/core/java/src/net/i2p/util/NativeBigInteger.java index 92be254145..9e98c5855f 100644 --- a/core/java/src/net/i2p/util/NativeBigInteger.java +++ b/core/java/src/net/i2p/util/NativeBigInteger.java @@ -96,8 +96,12 @@ public class NativeBigInteger extends BigInteger { * * Well, we really want to use Log so if you are one of those "other systems" * then comment out the I2PAppContext usage below. + * + * Set to false if not in router context, so scripts using TrustedUpdate + * don't spew log messages. main() below overrides to true. */ - private static final boolean _doLog = System.getProperty("jbigi.dontLog") == null; + private static boolean _doLog = System.getProperty("jbigi.dontLog") == null && + I2PAppContext.getGlobalContext().isRouterContext(); private final static String JBIGI_OPTIMIZATION_K6 = "k6"; private final static String JBIGI_OPTIMIZATION_K6_2 = "k62"; @@ -194,6 +198,7 @@ public class NativeBigInteger extends BigInteger { * Converts a BigInteger byte-array to a 'double' * @param ba Big endian twos complement representation of the BigInteger to convert to a double * @return The plain double-value represented by 'ba' + * @deprecated unused */ public native static double nativeDoubleValue(byte ba[]); @@ -245,6 +250,7 @@ public class NativeBigInteger extends BigInteger { return cachedBa; } + /** @deprecated unused */ @Override public double doubleValue() { if (_nativeOk) @@ -281,6 +287,7 @@ public class NativeBigInteger extends BigInteger { * */ public static void main(String args[]) { + _doLog = true; runModPowTest(100); // i2p doesn't care about the double values //runDoubleValueTest(100); @@ -354,6 +361,7 @@ public class NativeBigInteger extends BigInteger { } } +/******** private static void runDoubleValueTest(int numRuns) { System.out.println("DEBUG: Warming up the random number generator..."); SecureRandom rand = new SecureRandom(); @@ -408,6 +416,7 @@ public class NativeBigInteger extends BigInteger { System.out.println("However, we couldn't load the native library, so this doesn't test much"); } } +*********/ /** -- GitLab