java.util.logging
Thomas Leonard <tal-v5nx5w6akNyLE8xUarVfuPLx9OUvmyODWmv/[email protected]>
| Newsgroups | gmane.comp.lang.e.general |
|---|---|
| Organization | IT Innovation |
| Message-ID | <1290608088.12200.15.camel@farnia> |
How do people feel about replacing E's custom logging system with java.util.logging (part of the Java standard library since Java 1.4)? I tried just replacing the call in Traceln.java (patch attached), and it changes the default output from e.g. === 2010-11-24T13:54:36.581Z (Traceln.traceit:Traceln.java:90) WRN __main: > hi : (traceln) @ Traceln#run(String) @ run/1: </tmp/t.e#:span::1:7::1:7> to 24-Nov-2010 14:13:31 org.erights.e.elib.debug.Traceln traceit WARNING: hi (__main) @ Traceln#run(String) @ run/1: </tmp/t.e#:span::1:7::1:7> Any desired wrapping and escaping of the text can be done by adding a custom Formatter. With the default Java formatter, no wrapping or escaping is done (which is good for us, but a change from E's current output). -- Dr Thomas Leonard IT Innovation Centre 2 Venture Road Southampton Hampshire SO16 7NP Tel: +44 0 23 8076 0834 Fax: +44 0 23 8076 0833 mailto:tal-v5nx5w6akNyLE8xUarVfuPLx9OUvmyODWmv/[email protected] http://www.it-innovation.soton.ac.uk _______________________________________________ e-lang mailing list [email protected] http://www.eros-os.org/mailman/listinfo/e-lang
0001-Use-java.util.logging-for-traceln.patch
(text/x-patch, 3 KB)
>From b6b0bb2c64c2f16a2a32a03f1606645d98105143 Mon Sep 17 00:00:00 2001 From: Thomas Leonard <tal-v5nx5w6akNyLE8xUarVfuPLx9OUvmyODWmv/[email protected]> Date: Wed, 24 Nov 2010 13:58:15 +0000 Subject: [PATCH] Use java.util.logging for traceln --- src/jsrc/org/erights/e/elib/debug/Traceln.java | 36 ++++-------------------- 1 files changed, 6 insertions(+), 30 deletions(-) diff --git a/src/jsrc/org/erights/e/elib/debug/Traceln.java b/src/jsrc/org/erights/e/elib/debug/Traceln.java index 60057bc..d7422eb 100644 --- a/src/jsrc/org/erights/e/elib/debug/Traceln.java +++ b/src/jsrc/org/erights/e/elib/debug/Traceln.java @@ -3,13 +3,12 @@ package org.erights.e.elib.debug; -import org.erights.e.develop.format.StringHelper; -import org.erights.e.develop.trace.Trace; import org.erights.e.elib.vat.StackContext; import org.erights.e.elib.oldeio.EPrintable; import org.erights.e.elib.oldeio.TextWriter; import java.io.IOException; +import java.util.logging.Logger; /* ? def makeTraceln := <unsafe:org.erights.e.elib.debug.makeTraceln> @@ -27,11 +26,8 @@ import java.io.IOException; * @author Mark S. Miller */ public class Traceln implements EPrintable { - - static private final int LIMIT = 76; - private final String myHeader; - private final Trace myTracer; + private final Logger myLogger; /** * The header is for the purpose of secure labeling. @@ -44,7 +40,7 @@ public class Traceln implements EPrintable { */ public Traceln(String header) { myHeader = header; - myTracer = new Trace(header); + myLogger = Logger.getLogger(header); } /** @@ -64,31 +60,11 @@ public class Traceln implements EPrintable { } private void traceit(String message, boolean onlyOnePosFlag) { - if (myTracer.warning) { - StackContext sc = - new StackContext("traceln", onlyOnePosFlag, true); + // TODO: check that level >= warning before formatting? - // The following logic should behave like makeQuoteln.emaker + StackContext sc = new StackContext(myHeader, onlyOnePosFlag, true); - StringBuffer buf = new StringBuffer(message.length() * 2); - buf.append("\n> "); - int lineStart = buf.length(); - for (int i = 0, len = message.length(); i < len; i++) { - char c = message.charAt(i); - if ('\n' == c) { - buf.append("\n> "); - lineStart = buf.length(); - } else if (false && LIMIT <= buf.length() - lineStart) { - buf.append("\\\n> "); - lineStart = buf.length(); - StringHelper.escapedInto(c, buf); - } else { - StringHelper.escapedInto(c, buf); - } - } - buf.append('\n'); - myTracer.warningm(buf.toString(), sc); - } + myLogger.warning(message + "\n" + sc); } public void __printOn(TextWriter out) throws IOException { -- 1.7.1