Revision: 3603
http://vexi.svn.sourceforge.net/vexi/?rev=3603&view=rev
Author: mkpg2
Date: 2009-08-13 23:00:06 +0000 (Thu, 13 Aug 2009)
Log Message:
-----------
Fix build.
Modified Paths:
--------------
trunk/core/org.ibex.js/src/org/ibex/js/JSExn.jpp
trunk/core/org.vexi.devl/src/org/vexi/core/DevlTemplateBuilder.jpp
Removed Paths:
-------------
trunk/core/org.ibex.util/src/org/ibex/util/Log.java
Modified: trunk/core/org.ibex.js/src/org/ibex/js/JSExn.jpp
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/JSExn.jpp 2009-08-13 22:35:30 UTC
(rev 3602)
+++ trunk/core/org.ibex.js/src/org/ibex/js/JSExn.jpp 2009-08-13 23:00:06 UTC
(rev 3603)
@@ -69,8 +69,13 @@
}
public void printStackTrace() { printStackTrace(System.err); }
public void printStackTrace(PrintStream ps) { printStackTrace(new
PrintWriter(ps)); }
- public void printStackTrace(PrintWriter pw) { printStackTrace(pw,
Logger.DEBUG); }
- public void printStackTrace(Logger logger){ printStackTrace(new
PrintWriter(logger.logstream()),logger.level); }
+ public void printStackTrace(PrintWriter pw) {
+ printStackTrace(pw, Logger.DEBUG);
+ }
+ public void printStackTrace(int level, Logger logger){
+ if(level<=logger.level)
+ printStackTrace(new
PrintWriter(logger.logstream()),logger.level);
+ }
public void printStackTrace(PrintWriter pw, int level) {
int size = Math.min(backtrace.size(), MAX_BACKTRACE_SIZE);
pw.println(getMessage());
@@ -84,9 +89,7 @@
// java stack trace of the jsexn only gets printed when debug log
level is set.
if(level<=Logger.DEBUG) super.printStackTrace(pw);
else if(getCause()!=null){
- if((error && level<=Logger.WARN) ||
- (!error && level<=Logger.DEBUG))
- getCause().printStackTrace(pw);
+ if(error && level<=Logger.WARN) getCause().printStackTrace(pw);
}
pw.flush();
}
Deleted: trunk/core/org.ibex.util/src/org/ibex/util/Log.java
===================================================================
--- trunk/core/org.ibex.util/src/org/ibex/util/Log.java 2009-08-13 22:35:30 UTC
(rev 3602)
+++ trunk/core/org.ibex.util/src/org/ibex/util/Log.java 2009-08-13 23:00:06 UTC
(rev 3603)
@@ -1,317 +0,0 @@
-// Copyright 2000-2008 the Contributors, as shown in the revision logs.
-// Licensed under the Apache Software License 2.0 ("the License").
-// You may not use this file except in compliance with the License.
-
-package org.ibex.util;
-
-import java.io.*;
-import java.net.*;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-// FEATURE: logging exceptions should automatically unwrap exceptions
-
-/**
- * <p>
- * Logger distinguishes between System Logging (i.e. that of the vexi core)
- * - unexpected errors/warnings
- * - information used in core development
- *
- * and User Logging
- * - expected errors/warnings (bad inputs, network problems)
- * - logs called from vexi code
- * <p>
- * When calling Log.<i>logfunction</i> the first argument is always
- * information about what is being logged. For system logging it
- * should be a class or an object so that logs can be located in the
- * program easily. User logging is feedback to the person using the
- * program and so should display whatever makes most sense for the
- * program.
- * <p>
- * Based on the org.ibex.util.Log.
- *
- * @author [email protected]
- * @author [email protected]
- */
-
-public class Log {
- private static final SimpleDateFormat formatDate = new
SimpleDateFormat("EEE dd MMM yyyy");
- private static final SimpleDateFormat formatTime = new
SimpleDateFormat("[EEE HH:mm:ss] ");
- private static final Hashtable threadAnnotations = new Hashtable();
-
- //public static boolean on = System.getProperty("vexi.log.on",
"false").equals("true");
- public static boolean color = System.getProperty("vexi.log.color",
"false").equals("true");
- public static boolean verbose =
System.getProperty("vexi.log.verbose", "false").equals("true");
- public static boolean logDates = System.getProperty("vexi.log.dates",
"false").equals("true");
- public static boolean notes =
System.getProperty("vexi.log.notes.on", "true").equals("true");
- public static boolean stackTraces =
System.getProperty("vexi.log.stackTraces", "true").equals("true");
- public static int maximumNoteLength =
Integer.parseInt(System.getProperty("vexi.log.notes.maximumLength", (1024 *
32)+""));
- public static boolean rpc = false;
- public static int lastDay = -1;
-
- private static final int INDENT = 20;
- private static final String BLANKINDENT;
- static{
- String blankIndent="";
- while(blankIndent.length()<INDENT) blankIndent= " " + blankIndent;
- BLANKINDENT = blankIndent;
- }
-
- public static PrintStream logstream = System.err;
-
- public static void flush() { logstream.flush(); }
- public static void email(String address) { throw new Error("FIXME not
supported"); }
- public static void file(String filename) throws IOException {
- // FIXME security
- logstream = new PrintStream(new FileOutputStream(filename));
- }
- public static void tcp(String host, int port) throws IOException {
- // FIXME security
- logstream = new PrintStream(new Socket(InetAddress.getByName(host),
port).getOutputStream());
- }
-
- public static void setThreadAnnotation(String s) {
threadAnnotations.put(Thread.currentThread(), s); }
-
- /**
- * Notes can be used to attach log messages to the current thread
- * if you're not sure you want them in the log just yet.
- * Originally designed for retroactively logging socket-level
- * conversations only if an error is encountered
- */
- public static void note(String s) {
- if (!notes) return;
- StringBuffer notebuf = notebuf();
- notebuf.append(s);
- if (notebuf.length() > maximumNoteLength) {
- notebuf.reverse();
- notebuf.setLength(maximumNoteLength * 3 / 4);
- notebuf.reverse();
- }
- }
- public static void clearnotes() { if (!notes) return;
notebuf().setLength(0); }
-
- private static final HashMap notebufs = new HashMap();
- public static StringBuffer notebuf() {
- StringBuffer ret = (StringBuffer)notebufs.get(Thread.currentThread());
- if (ret == null) {
- ret = new StringBuffer(16 * 1024);
- notebufs.put(Thread.currentThread(), ret);
- }
- return ret;
- }
-
- /** true iff nothing has yet been logged */
- public static boolean firstMessage = true;
-
- // LOGGING APIS
- /** message can be a String or a Throwable */
-
- // System Logging
- public static synchronized void echo(Object o, Object message) { sLog(o,
message, ECHO); }
- public static synchronized void diag(Object o, Object message) { sLog(o,
message, DIAGNOSTIC); }
- public static synchronized void debug(Object o, Object message) { sLog(o,
message, DEBUG); }
- public static synchronized void info(Object o, Object message) { sLog(o,
message, INFO); }
- public static synchronized void warn(Object o, Object message) { sLog(o,
message, WARN); }
- public static synchronized void error(Object o, Object message) { sLog(o,
message, ERROR); }
-
- // User Logging
- public static synchronized void uDebug(Object o, Object message) { uLog(o,
null, message, DEBUG); }
- public static synchronized void uInfo(Object o, Object message) { uLog(o,
null, message, INFO); }
- public static synchronized void uWarn(Object o, Object message) { uLog(o,
null, message, WARN); }
- public static synchronized void uError(Object o, Object message) { uLog(o,
null, 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;
- private static final int ECHO = -1;
-
- // the usual log4j levels, minus FAIL (we just throw an Error in that case)
- public static final int DEBUG = 0;
- public static final int INFO = 1;
- public static final int WARN = 2;
- public static final int ERROR = 3;
- public static final int SILENT = Integer.MAX_VALUE;
- public static int sLevel = WARN; // INFO - Default during development
- public static int uLevel = INFO;
-
- // useful colors for output
- private static final int BLUE = 34;
- private static final int GREEN = 32;
- private static final int CYAN = 36;
- private static final int RED = 31;
- private static final int PURPLE = 35;
- private static final int BROWN = 33;
- private static final int GRAY = 37;
-
- private static String colorize(int color, boolean bright, String s) {
-
- if (!Log.color) return s;
- return
- "\033[40;" + (bright?"1;":"") + color + "m" +
- s +
- "\033[0m";
- }
-
- private static void sLog(Object o, Object message, int level) {
- if (level < Log.sLevel) return;
- log(o, null, message, level, true);
- }
-
- public static void uLog(Object major, Object minor, Object message, int
level) {
- if (level < Log.uLevel) return;
- log(major, minor, message, level, false);
- }
-
-
- // Info to describing the source of the logging. The 'major' is
- // printed on its own line (if it was different to the last major)
- // the minor is preprended to the log (and so has to be less than ~INDENT
chars)
- // Usually the minor is just the ln number when logging from vexi code.
- private static Object lastMajor = null;
- private static Object lastMinor = null; // usually the line number
-
- static synchronized void log(Object major, Object minor, Object message,
int level, boolean system) {
- Calendar cal = null;
- if (logDates) {
- cal = Calendar.getInstance();
- if (lastDay < 0 || lastDay != cal.get(Calendar.DAY_OF_YEAR)) {
- lastDay = cal.get(Calendar.DAY_OF_YEAR);
- String now = formatDate.format(cal.getTime());
- logstream.println();
- logstream.println(colorize(GREEN, false, "=== " + now + "
=========================================================="));
- }
- }
- if (firstMessage) {
- firstMessage = false;
- if(!logDates)
- logstream.println(colorize(GREEN, false,
"==========================================================================="));
-
- // FIXME later: causes problems with method pruning
- //diag(Log.class, "Logging enabled at " + new java.util.Date());
-
- if (color) diag(Log.class, "logging messages in " +
- colorize(BLUE, true, "c") +
- colorize(RED, true, "o") +
- colorize(CYAN, true, "l") +
- colorize(GREEN, true, "o") +
- colorize(PURPLE, true, "r"));
- }
-
- String where = whereString(major, system, cal);
-
-
- String annot = (String)threadAnnotations.get(Thread.currentThread());
- if (annot != null) where += annot;
-
- if (message instanceof Throwable) {
- if (level < ERROR) level = WARN;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- ((Throwable)message).printStackTrace(ps);
-
- if (notes && notebuf().length() > 0) {
- PrintWriter pw = new PrintWriter(baos);
- pw.println();
- pw.println("Thread notes:");
- pw.println(notebuf().toString());
- clearnotes();
- pw.flush();
- }
- ps.flush();
- byte[] b = baos.toByteArray();
- BufferedReader br = new BufferedReader(new InputStreamReader(new
ByteArrayInputStream(b)));
- try {
- if (stackTraces) {
- String s = null;
- String m = "";
- while((s = br.readLine()) != null) m += s + "\n";
- if (m.length() > 0) log(major, minor, m.substring(0,
m.length() - 1), level, system);
- } else {
- String m = br.readLine();
- int ok = 0;
- do {
- String s = br.readLine();
- if (s == null) break;
- if (s.indexOf('(') != -1) {
- String shortened = s.substring(s.indexOf('(')+1);
- shortened = shortened.substring(0,
shortened.indexOf(')'));
- m += " " + shortened;
- if (ok > 1) m = m.substring(0,
Math.min(m.length(), 78));
- ok++;
- }
- } while (m.length() < 78);
- log(major, minor, m, level, system);
- }
- //lastMajor = null;
- } catch (IOException e) {
- // FEATURE: use org.ibex.io.Stream's here
- logstream.println(colorize(RED, true, "Logger: exception
thrown by ByteArrayInputStream;" +
- " this should not happen"));
- }
- return;
- }
-
- String str = message.toString();
- // UNUSED if (str.indexOf('\n') != -1) lastWhere = "";
- while(str.indexOf('\t') != -1)
- str = str.substring(0, str.indexOf('\t')) + " " +
str.substring(str.indexOf('\t') + 1);
-
- where = colorize(GRAY, false, where);
- int levelcolor = GRAY;
- boolean bright = true;
- switch (level) {
- case DIAGNOSTIC: levelcolor = GREEN; bright = false; break;
- case ECHO: levelcolor = BLUE; bright = true; break;
- case DEBUG: levelcolor = BROWN; bright = true; break;
- case INFO: levelcolor = GRAY; bright = false; break;
- case WARN: levelcolor = BROWN; bright = false; break;
- case ERROR: levelcolor = RED; bright = true; break;
- }
-
- String whereMinor = null;
- if (!major.equals(lastMajor)) {
- if(minor!=null || where.length()+2>INDENT) {
- logstream.println(where);
- } else {
- whereMinor = where;
- }
- lastMajor = major;
- lastMinor = null;
- }
- if (whereMinor==null) whereMinor = (minor!=null &&
!minor.equals(lastMinor))? ""+minor + ": ":"";
- while (whereMinor.length() < INDENT) whereMinor = " " + whereMinor;
-
- whereMinor = colorize(GRAY,false,whereMinor);
-
- while (str.indexOf('\n') != -1) {
- logstream.println(whereMinor + colorize(levelcolor, bright,
str.substring(0, str.indexOf('\n'))));
- whereMinor = colorize(GRAY,false,BLANKINDENT);
- str = str.substring(str.indexOf('\n') + 1);
- }
- logstream.println(whereMinor + colorize(levelcolor, bright, str));
- }
-
- static private String whereString(Object major, boolean system, Calendar
cal){
- String where;
- if (major instanceof Class) {
- where = ((Class)major).getName();
- // This is a convention, which sortof hides the Java
implementation by just keeping the name without
- // the package. Which works when the name is functionally
relevant.
- if (where.indexOf('.') != -1) where =
where.substring(where.lastIndexOf('.') + 1);
- where = where.replace('$', '.');
- }
- else if (major instanceof String) where = (String)major;
- else where = major.getClass().getName();
- if (system)
- where = "[S] " + where;
-
- //if (where.length() > (logDates ? 14 : 20)) where = where.substring(0,
(logDates ? 14 : 20));
- //while (where.length() < (logDates ? 14 : 20)) where = " " + where;
- where = where + ": ";// (where.trim().length() == 0 ? " " : );
- if (cal!=null)
- where = formatTime.format(cal.getTime()) + where;
-
- return where;
-
- }
-
-}
Modified: trunk/core/org.vexi.devl/src/org/vexi/core/DevlTemplateBuilder.jpp
===================================================================
--- trunk/core/org.vexi.devl/src/org/vexi/core/DevlTemplateBuilder.jpp
2009-08-13 22:35:30 UTC (rev 3602)
+++ trunk/core/org.vexi.devl/src/org/vexi/core/DevlTemplateBuilder.jpp
2009-08-13 23:00:06 UTC (rev 3603)
@@ -38,7 +38,7 @@
if(JSU.S("static").equals(parent))
customStaticProps.add(js);
}
- public Logger getLogger() { return VexiLog.user; }
+ public Logger getLogger() { return Log.user; }
}
/** PerInstantiation globals checker*/
@@ -104,6 +104,6 @@
if(JSU.S("thisbox").equals(parent))
customBoxProps.add(js);
}
- public Logger getLogger() { return VexiLog.user; }
+ public Logger getLogger() { return Log.user; }
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn