2003/12/29 03:25:45
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:43:32 +0000 (07:43 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:43:32 +0000 (07:43 +0000)
darcs-hash:20040130074332-2ba56-2c543d04a9e9e195b0e2f626b6390f09863538a9.gz

src/org/xwt/translators/Freetype.java
src/org/xwt/translators/GIF.java
src/org/xwt/translators/PNG.java
src/org/xwt/translators/SVG.java
src/org/xwt/util/CachedInputStream.java
src/org/xwt/util/Log.java
src/org/xwt/util/Queue.java
src/org/xwt/util/SSL.java
src/org/xwt/util/Semaphore.java

index d9c6904..3bff602 100644 (file)
@@ -21,7 +21,7 @@ public class Freetype {
 
     public void loadFontByteStream(Res res) {
         try {
-            Log.log(this, "loading font " + res);
+            Log.info(this, "loading font " + res);
             loadedStream = res;
             InputStream is = res.getInputStream();
             byte[] fontstream = InputStreamToByteArray.convert(is);
@@ -34,7 +34,7 @@ public class Freetype {
             vm.execute();
             if(vm.getState() == Runtime.DONE) throw new Error("Freetype VM exited: " + vm.exitStatus());
         } catch (Exception e) {
-            Log.log(this, e);
+            Log.info(this, e);
         }
     }
 
@@ -59,7 +59,7 @@ public class Freetype {
             vm.copyin(addr, glyph.data, glyph.width * glyph.height);
             
         } catch (Exception e) {
-            Log.log(this, e);
+            Log.info(this, e);
         }
     }
 }
index d2cfed8..aa3f46a 100644 (file)
@@ -65,7 +65,7 @@ public class GIF {
         try {
             g._load(is, p);
         } catch (Exception e) {
-            if (Log.on) Log.log(GIF.class, e);
+            if (Log.on) Log.info(GIF.class, e);
             return;
         }
         // FIXME: must reset fields
index 6b7b11f..c20263f 100644 (file)
@@ -35,7 +35,7 @@ public class PNG {
             g._load(is, p);
             p.data = g.data;
         } catch (Exception e) {
-            if (Log.on) Log.log(PNG.class, e);
+            if (Log.on) Log.info(PNG.class, e);
             return;
         }
         // FIXME: must reset fields
@@ -59,7 +59,7 @@ public class PNG {
         // consume the header
         if ((inputStream.read() != 137) || (inputStream.read() != 80) || (inputStream.read() != 78) || (inputStream.read() != 71) ||
             (inputStream.read() != 13) || (inputStream.read() != 10) || (inputStream.read() != 26) || (inputStream.read() != 10)) {
-            Log.log(this, "PNG: error: input file is not a PNG file");
+            Log.info(this, "PNG: error: input file is not a PNG file");
             data = p.data = new int[] { };
             p.width = p.height = 0;
             return;
@@ -166,7 +166,7 @@ public class PNG {
     private void handletRNS() throws IOException {
         int chunkLen = chunkLength;
         if (palette == null) {
-            if (Log.on) Log.log(this, "warning: tRNS chunk encountered before pLTE; ignoring alpha channel");
+            if (Log.on) Log.info(this, "warning: tRNS chunk encountered before pLTE; ignoring alpha channel");
             inputStream.skip(chunkLength);
             return;
         }
index 8c22dd0..958d7a5 100644 (file)
@@ -16,7 +16,7 @@ public class SVG {
         props.put("fill", h.get("fill"));
         props.put("stroke", h.get("stroke"));
         if ("visible".equals(h.get("overflow")) || "auto".equals(h.get("overflow")))
-            Log.log(VectorGraphics.class, "warning: overflow={auto|visible} not supported; ignoring");
+            Log.info(VectorGraphics.class, "warning: overflow={auto|visible} not supported; ignoring");
         if (h.get("display") != null) props.put("invisible", new Boolean("none".equals(h.get("display"))));
 
 
@@ -147,7 +147,7 @@ public class SVG {
             path = s + (name.equals("polygon") ? "z" : "");
 
         } else {
-            Log.log(VectorGraphics.class, "unknown element in VectorGraphics namespace: " + name);
+            Log.info(VectorGraphics.class, "unknown element in VectorGraphics namespace: " + name);
         }
         props.put("path", path);
         t.keys = new String[props.size()];
index 2056a73..4e38954 100644 (file)
@@ -55,8 +55,8 @@ public class CachedInputStream {
                     cacheFileStream.close();
                     cacheFile.renameTo(diskCache);
                 } catch (IOException e) {
-                    Log.log(this, "exception thrown while writing disk cache");
-                    Log.log(this, e);
+                    Log.info(this, "exception thrown while writing disk cache");
+                    Log.info(this, e);
                 }
         }
         else size += ret;
index 0554f25..aa24171 100644 (file)
@@ -27,9 +27,11 @@ public class Log {
     public static void logJS(Object message) { log(JS.getSourceName() + ":" + JS.getLine(), message); }
 
     /** message can be a String or a Throwable */
-    public static synchronized void log(Object o, Object message) {
-        log(o, message, INFO);
-    }
+    public static synchronized void echo(Object o, Object message) { log(o, message, ECHO); }
+    public static synchronized void debug(Object o, Object message) { log(o, message, DEBUG); }
+    public static synchronized void info(Object o, Object message) { log(o, message, INFO); }
+    public static synchronized void warn(Object o, Object message) { log(o, message, WARN); }
+    public static synchronized void error(Object o, Object message) { log(o, message, ERROR); }
 
     // these two logging levels serve ONLY to change the color; semantically they are the same as DEBUG
     private static final int DIAGNOSTIC = -2;
index e2559e1..05a9073 100644 (file)
@@ -76,8 +76,8 @@ public class Queue {
                 wait();
             } catch (InterruptedException e) {
             } catch (Exception e) {
-                if (Log.on) Log.log(this, "exception in Queue.wait(); this should never happen");
-                if (Log.on) Log.log(this, e);
+                if (Log.on) Log.info(this, "exception in Queue.wait(); this should never happen");
+                if (Log.on) Log.info(this, e);
             }
         }
         
index c27bace..84fc575 100644 (file)
@@ -108,7 +108,7 @@ public class SSL extends Socket {
             while(true) {
                 String s2 = br.readLine();
                 if (s2 == null) return;
-                Log.log(SSL.class, s2);
+                Log.info(SSL.class, s2);
             }
             
         } catch (Exception e) {
@@ -241,21 +241,21 @@ public class SSL extends Socket {
             byte type;
             try { type = raw.readByte();
             } catch (EOFException e) {
-                if (Log.on) Log.log(this, "got EOFException reading packet type");
+                if (Log.on) Log.info(this, "got EOFException reading packet type");
                 return null;
             }
 
             byte ver_major = raw.readByte();
             byte ver_minor = raw.readByte();
             short len = raw.readShort();
-            if (Log.on) Log.log(this, "got record of type " + type + ", SSLv" + ver_major + "." + ver_minor + ", length=" + len);
+            if (Log.on) Log.info(this, "got record of type " + type + ", SSLv" + ver_major + "." + ver_minor + ", length=" + len);
 
             byte[] ret = new byte[len];
             raw.readFully(ret);
             
             // simply ignore ChangeCipherSpec messages -- we change as soon as we send ours
             if (type == 20) {
-                if (Log.on) Log.log(this, "got ChangeCipherSpec; ignoring");
+                if (Log.on) Log.info(this, "got ChangeCipherSpec; ignoring");
                 seq_num = 0;
                 return readRecord();
             }
@@ -282,23 +282,23 @@ public class SSL extends Socket {
                 if (decrypted_payload[1] > 1) {
                     throw new SSLException("got SSL ALERT message, level=" + decrypted_payload[0] + " code=" + decrypted_payload[1]);
                 } else if (decrypted_payload[1] == 0) {
-                    if (Log.on) Log.log(this, "server requested connection closure; returning null");
+                    if (Log.on) Log.info(this, "server requested connection closure; returning null");
                     return null;
                 } else {
-                    if (Log.on) Log.log(this, "got SSL ALERT message, level=" + decrypted_payload[0] + " code=" + decrypted_payload[1]);
+                    if (Log.on) Log.info(this, "got SSL ALERT message, level=" + decrypted_payload[0] + " code=" + decrypted_payload[1]);
                     return readRecord();
                 }
 
             } else if (type == 22) {
-                if (Log.on) Log.log(this, "read a handshake");
+                if (Log.on) Log.info(this, "read a handshake");
 
             } else if (type != 23) {
-                if (Log.on) Log.log(this, "unexpected record type: " + type + "; skipping");
+                if (Log.on) Log.info(this, "unexpected record type: " + type + "; skipping");
                 return readRecord();
 
             }
                 
-            if (Log.on) Log.log(this, "  returning " + decrypted_payload.length + " byte record payload");
+            if (Log.on) Log.info(this, "  returning " + decrypted_payload.length + " byte record payload");
             return decrypted_payload;
         }
 
@@ -325,7 +325,7 @@ public class SSL extends Socket {
 
                 switch(rec[0]) {
                 case 2: // ServerHello
-                    if (Log.on) Log.log(this, "got ServerHello");
+                    if (Log.on) Log.info(this, "got ServerHello");
                     byte ver_major = rec[4];
                     byte ver_minor = rec[5];
                     System.arraycopy(rec, 6, server_random, 0, server_random.length);
@@ -334,11 +334,11 @@ public class SSL extends Socket {
 
                     if (cipher_low == 0x04 || cipher_high != 0x00) {
                         export = false;
-                        if (Log.on) Log.log(this, "using SSL_RSA_WITH_RC4_128_MD5");
+                        if (Log.on) Log.info(this, "using SSL_RSA_WITH_RC4_128_MD5");
 
                     } else if (cipher_low == 0x03 || cipher_high != 0x00) {
                         export = true;
-                        if (Log.on) Log.log(this, "using SSL_RSA_EXPORT_WITH_RC4_40_MD5");
+                        if (Log.on) Log.info(this, "using SSL_RSA_EXPORT_WITH_RC4_40_MD5");
 
                     } else throw new SSLException("server asked for cipher " + ((cipher_high << 8) | cipher_low) +
                                                 " but we only do SSL_RSA_WITH_RC4_128_MD5 (0x0004) and " +
@@ -350,7 +350,7 @@ public class SSL extends Socket {
                     break;
                     
                 case 11: // Server's certificate(s)
-                    if (Log.on) Log.log(this, "got Server Certificate(s)");
+                    if (Log.on) Log.info(this, "got Server Certificate(s)");
                     int numcertbytes = ((rec[4] & 0xff) << 16) | ((rec[5] & 0xff) << 8) | (rec[6] & 0xff);
                     int numcerts = 0;
                     X509CertificateStructure last_cert = null;
@@ -407,7 +407,7 @@ public class SSL extends Socket {
                             if (!ignoreUntrustedCert && now.before(startDate))
                                 throw new SSLException("server certificate will not be valid until " + startDate);
 
-                            Log.log(this, "server cert (name, validity dates) checks out okay");
+                            Log.info(this, "server cert (name, validity dates) checks out okay");
                             
                         } else {
 
@@ -429,7 +429,7 @@ public class SSL extends Socket {
                         i += certlen + 3;
                         numcerts++;
                     }
-                    if (Log.on) Log.log(this, "  Certificate (" + numcerts + " certificates)");
+                    if (Log.on) Log.info(this, "  Certificate (" + numcerts + " certificates)");
 
                     if (ignoreUntrustedCert) break;
 
@@ -439,7 +439,7 @@ public class SSL extends Socket {
                     String subject = this_cert.getSubject().toString();
                     for(int i=0; i<trusted_CA_public_keys.length; i++) {
                         if (subject.indexOf(trusted_CA_public_key_identifiers[i]) != -1 && isSignedBy(this_cert, trusted_CA_public_keys[i])) {
-                            if (Log.on) Log.log(this, "pass 1: server cert was signed by trusted CA " + i);
+                            if (Log.on) Log.info(this, "pass 1: server cert was signed by trusted CA " + i);
                             good = true;
                             break;
                         }
@@ -449,7 +449,7 @@ public class SSL extends Socket {
                     if (!good)
                         for(int i=0; i<trusted_CA_public_keys.length; i++) {
                             if (isSignedBy(this_cert, trusted_CA_public_keys[i])) {
-                                if (Log.on) Log.log(this, "pass 2: server cert was signed by trusted CA " + i);
+                                if (Log.on) Log.info(this, "pass 2: server cert was signed by trusted CA " + i);
                                 good = true;
                                 break;
                             }
@@ -459,16 +459,16 @@ public class SSL extends Socket {
                     break;
 
                 case 12: 
-                    if (Log.on) Log.log(this, "got ServerKeyExchange");
+                    if (Log.on) Log.info(this, "got ServerKeyExchange");
                     serverKeyExchange = rec;
                     break;
 
                 case 13:
-                    if (Log.on) Log.log(this, "got Request for Client Certificates");
+                    if (Log.on) Log.info(this, "got Request for Client Certificates");
                     cert_requested = true;
                     break;
                     
-                case 14: if (Log.on) Log.log(this, "  ServerHelloDone"); return;
+                case 14: if (Log.on) Log.info(this, "  ServerHelloDone"); return;
                 default: throw new SSLException("unknown handshake of type " + rec[0]);
                 }
             }
@@ -491,7 +491,7 @@ public class SSL extends Socket {
                 if (expectedFinished[i] != rec[i + 4])
                     throw new SSLException("server Finished message mismatch!");
 
-            if (Log.on) Log.log(this, "server finished message checked out okay!");
+            if (Log.on) Log.info(this, "server finished message checked out okay!");
         }
    
     }
@@ -558,9 +558,9 @@ public class SSL extends Socket {
 
         public void sendClientHandshakes() throws IOException {
             
-            if (Log.on) Log.log(this, "shaking hands");
+            if (Log.on) Log.info(this, "shaking hands");
             if (cert_requested) {
-                if (Log.on) Log.log(this, "telling the server we have no certificates");
+                if (Log.on) Log.info(this, "telling the server we have no certificates");
                 writeHandshake(11, new byte[] { 0x0, 0x0, 0x0 });
             }
             
@@ -607,7 +607,7 @@ public class SSL extends Socket {
                         if (expectedSignature[i] != recievedSignature[i])
                             throw new SSLException("ServerKeyExchange message had invalid signature " + i);
 
-                    if (Log.on) Log.log(this, "ServerKeyExchange successfully processed");
+                    if (Log.on) Log.info(this, "ServerKeyExchange successfully processed");
                 }
 
                 AsymmetricBlockCipher rsa = new PKCS1(new RSAEngine());
@@ -623,7 +623,7 @@ public class SSL extends Socket {
             }
             
             // ChangeCipherSpec
-            if (Log.on) Log.log(this, "Handshake complete; sending ChangeCipherSpec");
+            if (Log.on) Log.info(this, "Handshake complete; sending ChangeCipherSpec");
             write(new byte[] { 0x01 }, 0, 1, (byte)20);
             seq_num = 0;
 
@@ -680,13 +680,13 @@ public class SSL extends Socket {
                                                       master_secret, pad1_sha } ) })
             }));
             raw.flush();
-            if (Log.on) Log.log(this, "wrote Finished message");
+            if (Log.on) Log.info(this, "wrote Finished message");
 
         }
         
         public void writeClientHello() throws IOException {
             
-            if (Log.on) Log.log(this, "sending ClientHello");
+            if (Log.on) Log.info(this, "sending ClientHello");
             int unixtime = (int)(System.currentTimeMillis() / (long)1000);
             
             byte[] out = new byte[] {
@@ -1541,7 +1541,7 @@ public class SSL extends Socket {
         for(int i=0; i<pad2_sha.length; i++) pad2_sha[i] = (byte)0x5C;
 
         try { 
-            if (Log.on) Log.log(SSL.class, "reading in trusted root public keys..."); 
+            if (Log.on) Log.info(SSL.class, "reading in trusted root public keys..."); 
             trusted_CA_public_keys = new SubjectPublicKeyInfo[base64_encoded_trusted_CA_public_keys.length / 2];
             trusted_CA_public_key_identifiers = new String[base64_encoded_trusted_CA_public_keys.length / 2];
             for(int i=0; i<base64_encoded_trusted_CA_public_keys.length; i+=2) {
@@ -1552,10 +1552,10 @@ public class SSL extends Socket {
             }
 
         } catch (Exception e) { 
-            if (Log.on) Log.log(SSL.class, e);
+            if (Log.on) Log.info(SSL.class, e);
         } 
         
-        if (Log.on) Log.log(SSL.class, "generating entropy..."); 
+        if (Log.on) Log.info(SSL.class, "generating entropy..."); 
         randpool = new byte[10];
         try { Thread.sleep(100); } catch (Exception e) { }
         for(int i=0; i<spinners.length; i++) {
@@ -1580,7 +1580,7 @@ public class SSL extends Socket {
         randpool = new byte[md5.getDigestSize()];
         md5.doFinal(randpool, 0);
 
-        if (Log.on) Log.log(SSL.class, "SSL is initialized."); 
+        if (Log.on) Log.info(SSL.class, "SSL is initialized."); 
         initializationFinished = true;
         SSL.class.notifyAll();
     } 
index 15d6ffc..673919d 100644 (file)
@@ -21,8 +21,8 @@ public class Semaphore {
                 wait();
             } catch (InterruptedException e) {
             } catch (Throwable e) {
-                if (Log.on) Log.log(this, "Exception in Semaphore.block(); this should never happen");
-                if (Log.on) Log.log(this, e);
+                if (Log.on) Log.info(this, "Exception in Semaphore.block(); this should never happen");
+                if (Log.on) Log.info(this, e);
             }
         }
         val--;