Thread: [Mathlib-commitlog] SF.net SVN: mathlib:[728] JMathLib/trunk/src/jmathlib/core/interpreter/ ErrorLo
Status: Beta
Brought to you by:
st_mueller
|
From: <st_...@us...> - 2009-01-23 15:27:06
|
Revision: 728
http://mathlib.svn.sourceforge.net/mathlib/?rev=728&view=rev
Author: st_mueller
Date: 2009-01-23 15:27:04 +0000 (Fri, 23 Jan 2009)
Log Message:
-----------
rearranched code
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/interpreter/ErrorLogger.java
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/ErrorLogger.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/ErrorLogger.java 2009-01-23 13:53:13 UTC (rev 727)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/ErrorLogger.java 2009-01-23 15:27:04 UTC (rev 728)
@@ -8,16 +8,31 @@
/**stores the size of indent for the next line*/
private static int indentSize = 0;
-
/**flags wether text should be indented*/
private static boolean displayIndent = false;
+ /**flag for logging mode of JMathLib*/
+ private static boolean debugB = false;
+
+ /**@return the setting of the debug flag*/
+ public static boolean getDebug()
+ {
+ return debugB;
+ }
+
+ /**sets the debug flag
+ @param _debug = should debug information be displayed*/
+ public static void setDebug(boolean _debug)
+ {
+ debugB = _debug;
+ }
+
/**display a debug line to the standard output and the file MathLib.log
@param text = the text to display*/
public static void debugLine(String text)
{
- if(getDebug())
+ if(debugB)
{
//if(displayIndent)
// text = text + ";" + indentSize;
@@ -33,9 +48,11 @@
}
catch(IOException error)
{
+ System.out.println("ERROR LOGGER: IOException");
}
catch(SecurityException error)
{
+ System.out.println("ERROR LOGGER: SecurityException");
}
System.out.println(text);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2009-02-08 17:11:15
|
Revision: 836
http://mathlib.svn.sourceforge.net/mathlib/?rev=836&view=rev
Author: st_mueller
Date: 2009-02-08 17:11:10 +0000 (Sun, 08 Feb 2009)
Log Message:
-----------
speed up the code
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/interpreter/ErrorLogger.java
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/ErrorLogger.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/ErrorLogger.java 2009-02-08 17:04:20 UTC (rev 835)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/ErrorLogger.java 2009-02-08 17:11:10 UTC (rev 836)
@@ -11,18 +11,20 @@
import java.io.*;
/**write error messages + debug information to a log file*/
-public class ErrorLogger extends RootObject
+public class ErrorLogger
{
- /**stores the size of indent for the next line*/
- private static int indentSize = 0;
+ /** indent string */
+ private static String indentS = "";
- /**flags wether text should be indented*/
- private static boolean displayIndent = false;
-
/**flag for logging mode of JMathLib*/
private static boolean debugB = false;
- /**@return the setting of the debug flag*/
+ /** handle to log file */
+ private static RandomAccessFile output = null;
+
+ /**
+ * @return the setting of the debug flag
+ */
public static boolean getDebug()
{
return debugB;
@@ -46,17 +48,22 @@
if(debugB)
{
- //if(displayIndent)
- // text = text + ";" + indentSize;
-
- for (int i=1; i<indentSize; i++) text= " "+text;
-
+ //for (int i=1; i<indentSize; i++) text= " "+text;
+ //text = new String( new byte[indentSize]) + text;
+ //text = indentS + text;
+
try
{
- RandomAccessFile output = new RandomAccessFile("JMathLib.log", "rw");
- output.seek(output.length());
- output.writeBytes(text + "\n");
- output.close();
+ // open log file only if it is not yet open
+ if (output == null)
+ {
+ System.out.println("ERROR LOGGER: OPENING FILE");
+ output = new RandomAccessFile("JMathLib.log", "rw");
+ output.seek(output.length());
+ }
+
+ //write log message
+ output.writeBytes(indentS + text + "\n");
}
catch(IOException error)
{
@@ -67,45 +74,70 @@
System.out.println("ERROR LOGGER: SecurityException");
}
- System.out.println(text);
+ // write log message to display
+ System.out.println(indentS + text);
}
}
+
+ /**
+ * Will release the file handle to the logfile
+ * @throws Throwable
+ */
+ public void finalize() throws Throwable
+ {
+ try
+ {
+ System.out.println("ERROR LOGGER FINALIZE");
+ output.close();
+ }
+ finally
+ {
+ super.finalize();
+ }
+ }
- /**display an integer to the standard output
- @param value = the number to display*/
+ /**
+ * display an integer to the standard output
+ * @param value = the number to display
+ */
public static void debugLine(int value)
{
debugLine(new Integer(value).toString());
}
- /**display a real value to the standard output
- @param value = the number to display*/
+ /**
+ * display a real value to the standard output
+ * @param value = the number to display
+ */
public static void debugLine(double value)
{
debugLine(new Double(value).toString());
}
- /**Increases the level of indent*/
+ /**
+ * Increases the level of indent
+ */
public static void increaseIndent()
{
- indentSize++;
+ indentS += " ";
}
- /**Decreases the level of indent*/
+ /**
+ * Decreases the level of indent
+ */
public static void decreaseIndent()
{
- if (indentSize>=0) indentSize--;
+ if (indentS.length()==0)
+ return;
+
+ indentS = indentS.substring(0, indentS.length()-1);
}
- /**Sets whether the indent value should be displayed
- @param _displayIndent = true if indent should be displayed*/
- public static void setDisplayIndent(boolean _displayIndent)
- {
- displayIndent = _displayIndent;
- }
-
- /**Prints the current execution stack trace, the list of functions that have been called up to the current one.
- @param message = The message to display before the stack trace*/
+ /**
+ * Prints the current execution stack trace, the list of
+ * functions that have been called up to the current one.
+ * @param message = The message to display before the stack trace
+ */
public static void displayStackTrace(String message)
{
new Exception(message).printStackTrace();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|