Revision: 3620
          http://vexi.svn.sourceforge.net/vexi/?rev=3620&view=rev
Author:   mkpg2
Date:     2009-08-24 21:28:40 +0000 (Mon, 24 Aug 2009)

Log Message:
-----------
Fix. Error logging.

Modified Paths:
--------------
    trunk/core/org.ibex.js/src/org/ibex/js/JSExn.jpp
    trunk/core/org.ibex.js/src/org/ibex/js/Scheduler.java
    trunk/core/org.ibex.util/src/org/ibex/util/IbexLogger.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-24 16:38:28 UTC 
(rev 3619)
+++ trunk/core/org.ibex.js/src/org/ibex/js/JSExn.jpp    2009-08-24 21:28:40 UTC 
(rev 3620)
@@ -23,15 +23,9 @@
 
     final Basket.List backtrace = new Basket.Array();
     final private ExnJSObj js ;
-    final boolean error;
     
     public JSExn(InterruptedException e) {
-       super(e);
-       this.js = new ExnJSObj(
-                       JSU.S("JS thread interrupted")
-                       , SC_interrupted); 
-       fill(null);
-       this.error = false;
+       this(JSU.S("JS thread interrupted"), SC_interrupted); 
     }
     public JSExn(Throwable e) {
        this("Unexpected Java exception thrown by the core\n" + 
e.getClass().getName() + ":" + e.getMessage(),e);
@@ -42,7 +36,6 @@
                        JSU.S(msg)
                        , SC_error); 
        fill(null);
-       this.error = true;
     }
     public JSExn(String s) { this(JSU.S(s)); }
     public JSExn(JS msg) { this(msg,null); }
@@ -50,7 +43,6 @@
     public JSExn(JS msg, JS type, Interpreter cx) { 
        this.js = new ExnJSObj(msg,type);
        fill(cx); 
-       this.error = false;
     }
     
     void fillIfEmpty(Interpreter cx){
@@ -72,7 +64,7 @@
        printStackTrace(pw, Logger.DEBUG); 
     }    
     public void printStackTrace(int level, Logger logger, Object o){
-       if(level<=logger.getLevel()){
+       if(level>=logger.getLevel()){
                StringWriter sw = new StringWriter(1024);
                PrintWriter pw = new PrintWriter(sw);
                printStackTrace(pw,logger.getLevel());
@@ -92,7 +84,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) getCause().printStackTrace(pw);
+               if(level<=Logger.WARN)  getCause().printStackTrace(pw);
         }
         pw.flush();
     }

Modified: trunk/core/org.ibex.js/src/org/ibex/js/Scheduler.java
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/Scheduler.java       2009-08-24 
16:38:28 UTC (rev 3619)
+++ trunk/core/org.ibex.js/src/org/ibex/js/Scheduler.java       2009-08-24 
21:28:40 UTC (rev 3620)
@@ -100,16 +100,15 @@
                                        if(quitOnExn)
                                                return e;
                                        
-                                       String message;
                                        // FIXME - are these messages always 
accurate(!) Could look at current
                                        // task for more information
                                        if(e instanceof JSExn){
-                                               message = "A JavaScript thread 
spawned with vexi.thread threw an exception:"; 
+                                               logger.error(Scheduler.class, 
"A JavaScript thread spawned with vexi.thread threw an exception:");
+                                               
((JSExn)e).printStackTrace(Logger.ERROR, logger, Scheduler.class);
                                        }else{
-                                               message = "A Callable threw an 
exception which was caught by the scheduler:";
+                                               logger.error(Scheduler.class, 
"A Callable threw an exception which was caught by the scheduler:");
+                                               logger.error(Scheduler.class, 
e);
                                        }
-                                       logger.error(Scheduler.class, message);
-                                       logger.error(Scheduler.class, e);
                                }
                                // if an Error is thrown it will cause the 
engine to quit
                        }

Modified: trunk/core/org.ibex.util/src/org/ibex/util/IbexLogger.java
===================================================================
--- trunk/core/org.ibex.util/src/org/ibex/util/IbexLogger.java  2009-08-24 
16:38:28 UTC (rev 3619)
+++ trunk/core/org.ibex.util/src/org/ibex/util/IbexLogger.java  2009-08-24 
21:28:40 UTC (rev 3620)
@@ -225,7 +225,10 @@
         whereMinor = colorize(GRAY,false,whereMinor);
         
         while (str.indexOf('\n') != -1) {
-            logstream.println(whereMinor + colorize(levelcolor, bright, 
str.substring(0, str.indexOf('\n'))));
+               String line = str.substring(0, str.indexOf('\n'));
+               // HACK - jsexn logging uses \r\n for newlines
+               if(line.charAt(line.length()-1)=='\r') line = 
line.substring(0,line.length()-1);
+            logstream.println(whereMinor + colorize(levelcolor, bright, line));
             whereMinor = colorize(GRAY,false,BLANKINDENT);
             str = str.substring(str.indexOf('\n') + 1);
         }


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

Reply via email to