Changeset 8235
- Timestamp:
- 2004-10-08T09:12:27+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/Gatherer.java
r8233 r8235 110 110 /** A static reference to ourselves. */ 111 111 static public Gatherer self; 112 /** The debug print stream. */113 static public PrintStream debug;114 112 /** We are using the GLI for GS3 */ 115 113 static public boolean GS3 = false; … … 176 174 } 177 175 // Create the debug stream only if required. 178 if(debug_enabled) { 179 try { 180 Calendar now = Calendar.getInstance(); 181 StringBuffer name = new StringBuffer("debug"); 182 name.append(now.get(Calendar.DATE)); 183 name.append("-"); 184 name.append(now.get(Calendar.MONTH)); 185 name.append("-"); 186 name.append(now.get(Calendar.YEAR)); 187 name.append(".txt"); 188 189 // Debug file is created in the GLI directory, unless the GLI is running as an applet 190 String debug_file_path = name.toString(); 191 if (isGsdlRemote) { 192 debug_file_path = Utility.getGLIUserFolder().toString() + File.separator + debug_file_path; 193 } 194 Gatherer.println("Debug file path: " + debug_file_path); 195 this.debug = new PrintStream(new FileOutputStream(debug_file_path)); 196 197 Properties props = System.getProperties(); 198 props.list(debug); 199 } 200 catch(Exception error) { 201 ///ystem.err.println("Error in Gatherer.init(): " + error); 202 error.printStackTrace(); 203 System.exit(1); 204 } 176 if (debug_enabled) { 177 DebugStream.enableDebugging(); 178 179 Calendar now = Calendar.getInstance(); 180 StringBuffer name = new StringBuffer("debug"); 181 name.append(now.get(Calendar.DATE)); 182 name.append("-"); 183 name.append(now.get(Calendar.MONTH)); 184 name.append("-"); 185 name.append(now.get(Calendar.YEAR)); 186 name.append(".txt"); 187 188 // Debug file is created in the GLI directory, unless the GLI is running as an applet 189 String debug_file_path = name.toString(); 190 if (isGsdlRemote) { 191 debug_file_path = Utility.getGLIUserFolder().toString() + File.separator + debug_file_path; 192 } 193 DebugStream.println("Debug file path: " + debug_file_path); 194 DebugStream.setDebugFile(debug_file_path); 195 DebugStream.print(System.getProperties()); 205 196 } 206 197 try { … … 454 445 455 446 // Flush debug 456 if(debug != null) { 457 try { 458 debug.flush(); 459 debug.close(); 460 } 461 catch (Exception error) { 462 error.printStackTrace(); 463 } 464 } 447 DebugStream.closeDebugStream(); 465 448 466 449 // If we started a server, we should try to stop it. … … 632 615 /** Print a message to the debug stream. */ 633 616 static synchronized public void print(String message) { 634 if(debug != null) { 635 debug.print(message); 636 System.err.print(message); 637 } 617 DebugStream.print(message); 638 618 } 639 619 /** Print a message to the debug stream. */ 640 620 static synchronized public void println(String message) { 641 if(debug != null) { 642 debug.println(message); 643 System.err.println(message); 644 } 621 DebugStream.println(message); 645 622 } 646 623 647 624 /** Print a stack trace to the debug stream. */ 648 625 static synchronized public void printStackTrace(Exception exception) { 649 if (debug != null) { 650 exception.printStackTrace(debug); 651 } 652 exception.printStackTrace(); 626 DebugStream.printStackTrace(exception); 653 627 } 654 628 … … 985 959 // mozilla and netscape, try using a remote command to get things in the same window 986 960 String [] new_commands = new String[] {prog_name, "-raise", "-remote", "openURL("+url+",new-tab)"}; 987 if(debug != null) { 988 printArray(new_commands); 989 } 961 printArray(new_commands); 962 990 963 Runtime rt = Runtime.getRuntime(); 991 964 process = rt.exec(new_commands); … … 993 966 if (exitCode != 0) { // if Netscape or mozilla was not open 994 967 Gatherer.println("couldn't do remote, trying original command"); 995 if(debug != null) { 996 printArray(commands); 997 } 968 printArray(commands); 998 969 process = rt.exec(commands); // try the original command 999 970 } … … 1026 997 public void printArray(String [] array) { 1027 998 for(int i = 0; i < array.length; i++) { 1028 debug.print(array[i]+" ");999 DebugStream.print(array[i]+" "); 1029 1000 System.err.println(array[i]+" "); 1030 1001 }
Note:
See TracChangeset
for help on using the changeset viewer.