Changeset 2857


Ignore:
Timestamp:
06/12/07 11:46:15 (12 years ago)
Author:
curtis
Message:

Fix up Bio-Formats logging to use a simple, common logging infrastructure.

Location:
trunk/loci/formats
Files:
2 added
47 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/AxisGuesser.java

    r2601 r2857  
    284284      new Location(System.getProperty("user.dir")).listFiles()[0] : 
    285285      new Location(args[0]); 
    286     System.out.println("File = " + file.getAbsoluteFile()); 
     286    LogTools.println("File = " + file.getAbsoluteFile()); 
    287287    String pat = FilePattern.findPattern(file); 
    288     if (pat == null) System.out.println("No pattern found."); 
     288    if (pat == null) LogTools.println("No pattern found."); 
    289289    else { 
    290       System.out.println("Pattern = " + pat); 
     290      LogTools.println("Pattern = " + pat); 
    291291      FilePattern fp = new FilePattern(pat); 
    292292      if (fp.isValid()) { 
    293         System.out.println("Pattern is valid."); 
     293        LogTools.println("Pattern is valid."); 
    294294        String id = fp.getFiles()[0]; 
    295295        if (!new Location(id).exists()) { 
    296           System.out.println("File '" + id + "' does not exist."); 
     296          LogTools.println("File '" + id + "' does not exist."); 
    297297        } 
    298298        else { 
    299299          // read dimensional information from first file 
    300           System.out.print("Reading first file "); 
     300          LogTools.print("Reading first file "); 
    301301          ImageReader reader = new ImageReader(); 
    302302          reader.setId(id); 
     
    307307          boolean certain = reader.isOrderCertain(); 
    308308          reader.close(); 
    309           System.out.println("[done]"); 
    310           System.out.println("\tdimOrder = " + dimOrder + 
     309          LogTools.println("[done]"); 
     310          LogTools.println("\tdimOrder = " + dimOrder + 
    311311            (certain ? " (certain)" : " (uncertain)")); 
    312           System.out.println("\tsizeZ = " + sizeZ); 
    313           System.out.println("\tsizeT = " + sizeT); 
    314           System.out.println("\tsizeC = " + sizeC); 
     312          LogTools.println("\tsizeZ = " + sizeZ); 
     313          LogTools.println("\tsizeT = " + sizeT); 
     314          LogTools.println("\tsizeC = " + sizeC); 
    315315 
    316316          // guess axes 
     
    323323          int[] axes = ag.getAxisTypes(); 
    324324          String newOrder = ag.getAdjustedOrder(); 
    325           System.out.println("Axis types:"); 
     325          LogTools.println("Axis types:"); 
    326326          for (int i=0; i<blocks.length; i++) { 
    327327            String axis; 
     
    339339                axis = "?"; 
    340340            } 
    341             System.out.println("\t" + blocks[i] + "\t" + 
     341            LogTools.println("\t" + blocks[i] + "\t" + 
    342342              axis + " (prefix = " + prefixes[i] + ")"); 
    343343          } 
    344344          if (!dimOrder.equals(newOrder)) { 
    345             System.out.println("Adjusted dimension order = " + newOrder); 
     345            LogTools.println("Adjusted dimension order = " + newOrder); 
    346346          } 
    347347        } 
    348348      } 
    349       else System.out.println("Pattern is invalid: " + fp.getErrorMessage()); 
     349      else LogTools.println("Pattern is invalid: " + fp.getErrorMessage()); 
    350350    } 
    351351  } 
  • trunk/loci/formats/ClassList.java

    r2655 r2857  
    8686      try { c = Class.forName(line); } 
    8787      catch (ClassNotFoundException exc) { 
    88         if (FormatHandler.debug) exc.printStackTrace(); 
     88        if (FormatHandler.debug) LogTools.trace(exc); 
    8989      } 
    9090      catch (NoClassDefFoundError err) { 
    91         if (FormatHandler.debug) err.printStackTrace(); 
     91        if (FormatHandler.debug) LogTools.trace(err); 
    9292      } 
    9393      catch (ExceptionInInitializerError err) { 
    94         if (FormatHandler.debug) err.printStackTrace(); 
     94        if (FormatHandler.debug) LogTools.trace(err); 
    9595      } 
    9696      if (c == null || (base != null && !base.isAssignableFrom(c))) { 
    97         System.err.println("Error: \"" + line + "\" is not valid."); 
     97        LogTools.println("Error: \"" + line + "\" is not valid."); 
    9898        continue; 
    9999      } 
  • trunk/loci/formats/ConsoleTools.java

    r2799 r2857  
    9797          } 
    9898          else if (args[i].equals("-map")) map = args[++i]; 
    99           else System.out.println("Ignoring unknown command flag: " + args[i]); 
     99          else LogTools.println("Ignoring unknown command flag: " + args[i]); 
    100100        } 
    101101        else { 
    102102          if (id == null) id = args[i]; 
    103           else System.out.println("Ignoring unknown argument: " + args[i]); 
     103          else LogTools.println("Ignoring unknown argument: " + args[i]); 
    104104        } 
    105105      } 
    106106    } 
    107107    if (FormatHandler.debug) { 
    108       System.out.println("Debugging at level " + FormatHandler.debugLevel); 
     108      LogTools.println("Debugging at level " + FormatHandler.debugLevel); 
    109109    } 
    110110    if (id == null) { 
    111111      String className = reader.getClass().getName(); 
    112       String format = reader.getFormat(); 
     112      String fmt = reader instanceof ImageReader ? "any" : reader.getFormat(); 
    113113      String[] s = { 
    114         "To test read a file in " + format + " format, run:", 
     114        "To test read a file in " + fmt + " format, run:", 
    115115        "  java " + className + " [-nopix] [-nometa] [-thumbs] [-minmax]", 
    116116        "    [-merge] [-stitch] [-separate] [-omexml] [-normalize]", 
     
    136136        "" 
    137137      }; 
    138       for (int i=0; i<s.length; i++) System.out.println(s[i]); 
     138      for (int i=0; i<s.length; i++) LogTools.println(s[i]); 
    139139      return false; 
    140140    } 
     
    156156      // determine format 
    157157      ImageReader ir = (ImageReader) reader; 
    158       System.out.print("Checking file format "); 
    159       System.out.println("[" + ir.getFormat(id) + "]"); 
     158      LogTools.print("Checking file format "); 
     159      LogTools.println("[" + ir.getFormat(id) + "]"); 
    160160    } 
    161161    else { 
    162162      // verify format 
    163       System.out.print("Checking " + reader.getFormat() + " format "); 
    164       System.out.println(reader.isThisType(id) ? "[yes]" : "[no]"); 
    165     } 
    166  
    167     System.out.println("Initializing reader"); 
     163      LogTools.print("Checking " + reader.getFormat() + " format "); 
     164      LogTools.println(reader.isThisType(id) ? "[yes]" : "[no]"); 
     165    } 
     166 
     167    LogTools.println("Initializing reader"); 
    168168    if (stitch) { 
    169169      reader = new FileStitcher(reader, true); 
     
    187187    long e1 = System.currentTimeMillis(); 
    188188    float sec1 = (e1 - s1) / 1000f; 
    189     System.out.println("Initialization took " + sec1 + "s"); 
     189    LogTools.println("Initialization took " + sec1 + "s"); 
    190190 
    191191    if (!normalize && reader.getPixelType() == FormatTools.FLOAT) { 
     
    195195 
    196196    // read basic metadata 
    197     System.out.println(); 
    198     System.out.println("Reading core metadata"); 
    199     System.out.println(stitch ? 
     197    LogTools.println(); 
     198    LogTools.println("Reading core metadata"); 
     199    LogTools.println(stitch ? 
    200200      "File pattern = " + id : "Filename = " + reader.getCurrentFile()); 
    201     if (map != null) System.out.println("Mapped filename = " + map); 
     201    if (map != null) LogTools.println("Mapped filename = " + map); 
    202202    String[] used = reader.getUsedFiles(); 
    203203    boolean usedValid = used != null && used.length > 0; 
     
    211211    } 
    212212    if (!usedValid) { 
    213       System.out.println( 
     213      LogTools.println( 
    214214        "************ Warning: invalid used files list ************"); 
    215215    } 
    216216    if (used == null) { 
    217       System.out.println("Used files = null"); 
     217      LogTools.println("Used files = null"); 
    218218    } 
    219219    else if (used.length == 0) { 
    220       System.out.println("Used files = []"); 
     220      LogTools.println("Used files = []"); 
    221221    } 
    222222    else if (used.length > 1) { 
    223       System.out.println("Used files:"); 
    224       for (int u=0; u<used.length; u++) System.out.println("\t" + used[u]); 
     223      LogTools.println("Used files:"); 
     224      for (int u=0; u<used.length; u++) LogTools.println("\t" + used[u]); 
    225225    } 
    226226    else if (!id.equals(used[0])) { 
    227       System.out.println("Used files = [" + used[0] + "]"); 
     227      LogTools.println("Used files = [" + used[0] + "]"); 
    228228    } 
    229229    int seriesCount = reader.getSeriesCount(); 
    230     System.out.println("Series count = " + seriesCount); 
     230    LogTools.println("Series count = " + seriesCount); 
    231231    for (int j=0; j<seriesCount; j++) { 
    232232      reader.setSeries(j); 
     
    253253 
    254254      // output basic metadata for series #i 
    255       System.out.println("Series #" + j + ":"); 
    256       System.out.println("\tImage count = " + imageCount); 
    257       System.out.print("\tRGB = " + rgb + " (" + rgbChanCount + ")"); 
    258       if (merge) System.out.print(" (merged)"); 
    259       else if (separate) System.out.print(" (separated)"); 
     255      LogTools.println("Series #" + j + ":"); 
     256      LogTools.println("\tImage count = " + imageCount); 
     257      LogTools.print("\tRGB = " + rgb + " (" + rgbChanCount + ")"); 
     258      if (merge) LogTools.print(" (merged)"); 
     259      else if (separate) LogTools.print(" (separated)"); 
    260260      if (rgb != (rgbChanCount != 1)) { 
    261         System.out.println("\t************ Warning: RGB mismatch ************"); 
    262       } 
    263       System.out.println(); 
    264       System.out.println("\tInterleaved = " + interleaved); 
    265       System.out.println("\tWidth = " + sizeX); 
    266       System.out.println("\tHeight = " + sizeY); 
    267       System.out.println("\tSizeZ = " + sizeZ); 
    268       System.out.println("\tSizeT = " + sizeT); 
    269       System.out.print("\tSizeC = " + sizeC); 
     261        LogTools.println("\t************ Warning: RGB mismatch ************"); 
     262      } 
     263      LogTools.println(); 
     264      LogTools.println("\tInterleaved = " + interleaved); 
     265      LogTools.println("\tWidth = " + sizeX); 
     266      LogTools.println("\tHeight = " + sizeY); 
     267      LogTools.println("\tSizeZ = " + sizeZ); 
     268      LogTools.println("\tSizeT = " + sizeT); 
     269      LogTools.print("\tSizeC = " + sizeC); 
    270270      if (sizeC != effSizeC) { 
    271         System.out.print(" (effectively " + effSizeC + ")"); 
     271        LogTools.print(" (effectively " + effSizeC + ")"); 
    272272      } 
    273273      int cProduct = 1; 
     
    276276      } 
    277277      else { 
    278         System.out.print(" ("); 
     278        LogTools.print(" ("); 
    279279        for (int i=0; i<cLengths.length; i++) { 
    280           if (i > 0) System.out.print(" x "); 
    281           System.out.print(cLengths[i] + " " + cTypes[i]); 
     280          if (i > 0) LogTools.print(" x "); 
     281          LogTools.print(cLengths[i] + " " + cTypes[i]); 
    282282          cProduct *= cLengths[i]; 
    283283        } 
    284         System.out.print(")"); 
    285       } 
    286       System.out.println(); 
     284        LogTools.print(")"); 
     285      } 
     286      LogTools.println(); 
    287287      if (cLengths.length == 0 || cProduct != sizeC) { 
    288         System.out.println( 
     288        LogTools.println( 
    289289          "\t************ Warning: C dimension mismatch ************"); 
    290290      } 
    291291      if (imageCount != sizeZ * effSizeC * sizeT) { 
    292         System.out.println("\t************ Warning: ZCT mismatch ************"); 
    293       } 
    294       System.out.println("\tThumbnail size = " + 
     292        LogTools.println("\t************ Warning: ZCT mismatch ************"); 
     293      } 
     294      LogTools.println("\tThumbnail size = " + 
    295295        thumbSizeX + " x " + thumbSizeY); 
    296       System.out.println("\tEndianness = " + 
     296      LogTools.println("\tEndianness = " + 
    297297        (little ? "intel (little)" : "motorola (big)")); 
    298       System.out.println("\tDimension order = " + dimOrder + 
     298      LogTools.println("\tDimension order = " + dimOrder + 
    299299        (orderCertain ? " (certain)" : " (uncertain)")); 
    300       System.out.println("\tPixel type = " + 
     300      LogTools.println("\tPixel type = " + 
    301301        FormatTools.getPixelTypeString(pixelType)); 
    302302      if (doMeta) { 
    303         System.out.println("\t-----"); 
     303        LogTools.println("\t-----"); 
    304304        int[] indices; 
    305305        if (imageCount > 6) { 
     
    319319          zct[i] = reader.getZCTCoords(indices[i]); 
    320320          indices2[i] = reader.getIndex(zct[i][0], zct[i][1], zct[i][2]); 
    321           System.out.print("\tPlane #" + indices[i] + " <=> Z " + zct[i][0] + 
     321          LogTools.print("\tPlane #" + indices[i] + " <=> Z " + zct[i][0] + 
    322322            ", C " + zct[i][1] + ", T " + zct[i][2]); 
    323323          if (indices[i] != indices2[i]) { 
    324             System.out.println(" [mismatch: " + indices2[i] + "]"); 
    325           } 
    326           else System.out.println(); 
     324            LogTools.println(" [mismatch: " + indices2[i] + "]"); 
     325          } 
     326          else LogTools.println(); 
    327327        } 
    328328      } 
     
    356356    // read pixels 
    357357    if (pixels) { 
    358       System.out.println(); 
    359       System.out.print("Reading" + s + " pixel data "); 
     358      LogTools.println(); 
     359      LogTools.print("Reading" + s + " pixel data "); 
    360360      status.setVerbose(false); 
    361361      int num = reader.getImageCount(); 
     
    366366      if (end < start) end = start; 
    367367 
    368       System.out.print("(" + start + "-" + end + ") "); 
     368      LogTools.print("(" + start + "-" + end + ") "); 
    369369      BufferedImage[] images = new BufferedImage[end - start + 1]; 
    370370      long s2 = System.currentTimeMillis(); 
     
    394394        if (pixType != pixelType && !fastBlit) { 
    395395          if (!mismatch) { 
    396             System.out.println(); 
     396            LogTools.println(); 
    397397            mismatch = true; 
    398398          } 
    399           System.out.println("\tPlane #" + i + ": pixel type mismatch: " + 
     399          LogTools.println("\tPlane #" + i + ": pixel type mismatch: " + 
    400400            FormatTools.getPixelTypeString(pixType) + "/" + 
    401401            FormatTools.getPixelTypeString(pixelType)); 
     
    403403        else { 
    404404          mismatch = false; 
    405           System.out.print("."); 
     405          LogTools.print("."); 
    406406        } 
    407407      } 
    408408      long e2 = System.currentTimeMillis(); 
    409       if (!mismatch) System.out.print(" "); 
    410       System.out.println("[done]"); 
     409      if (!mismatch) LogTools.print(" "); 
     410      LogTools.println("[done]"); 
    411411 
    412412      // output timing results 
    413413      float sec2 = (e2 - s2) / 1000f; 
    414414      float avg = (float) (e2 - s2) / images.length; 
    415       System.out.println(sec2 + "s elapsed (" + avg + "ms per image)"); 
     415      LogTools.println(sec2 + "s elapsed (" + avg + "ms per image)"); 
    416416 
    417417      if (minmax) { 
     
    432432 
    433433        // output min/max results 
    434         System.out.println(); 
    435         System.out.println("Min/max values:"); 
     434        LogTools.println(); 
     435        LogTools.println("Min/max values:"); 
    436436        for (int c=0; c<sizeC; c++) { 
    437           System.out.println("\tChannel " + c + ":"); 
    438           System.out.println("\t\tGlobal minimum = " + 
     437          LogTools.println("\tChannel " + c + ":"); 
     438          LogTools.println("\t\tGlobal minimum = " + 
    439439            globalMin[c] + " (initially " + preGlobalMin[c] + ")"); 
    440           System.out.println("\t\tGlobal maximum = " + 
     440          LogTools.println("\t\tGlobal maximum = " + 
    441441            globalMax[c] + " (initially " + preGlobalMax[c] + ")"); 
    442           System.out.println("\t\tKnown minimum = " + 
     442          LogTools.println("\t\tKnown minimum = " + 
    443443            knownMin[c] + " (initially " + preKnownMin[c] + ")"); 
    444           System.out.println("\t\tKnown maximum = " + 
     444          LogTools.println("\t\tKnown maximum = " + 
    445445            knownMax[c] + " (initially " + preKnownMax[c] + ")"); 
    446446        } 
    447         System.out.print("\tFirst plane minimum(s) ="); 
    448         if (planeMin == null) System.out.print(" none"); 
     447        LogTools.print("\tFirst plane minimum(s) ="); 
     448        if (planeMin == null) LogTools.print(" none"); 
    449449        else { 
    450450          for (int subC=0; subC<planeMin.length; subC++) { 
    451             System.out.print(" " + planeMin[subC]); 
    452           } 
    453         } 
    454         System.out.print(" (initially"); 
    455         if (prePlaneMin == null) System.out.print(" none"); 
     451            LogTools.print(" " + planeMin[subC]); 
     452          } 
     453        } 
     454        LogTools.print(" (initially"); 
     455        if (prePlaneMin == null) LogTools.print(" none"); 
    456456        else { 
    457457          for (int subC=0; subC<prePlaneMin.length; subC++) { 
    458             System.out.print(" " + prePlaneMin[subC]); 
    459           } 
    460         } 
    461         System.out.println(")"); 
    462         System.out.print("\tFirst plane maximum(s) ="); 
    463         if (planeMax == null) System.out.print(" none"); 
     458            LogTools.print(" " + prePlaneMin[subC]); 
     459          } 
     460        } 
     461        LogTools.println(")"); 
     462        LogTools.print("\tFirst plane maximum(s) ="); 
     463        if (planeMax == null) LogTools.print(" none"); 
    464464        else { 
    465465          for (int subC=0; subC<planeMax.length; subC++) { 
    466             System.out.print(" " + planeMax[subC]); 
    467           } 
    468         } 
    469         System.out.print(" (initially"); 
    470         if (prePlaneMax == null) System.out.print(" none"); 
     466            LogTools.print(" " + planeMax[subC]); 
     467          } 
     468        } 
     469        LogTools.print(" (initially"); 
     470        if (prePlaneMax == null) LogTools.print(" none"); 
    471471        else { 
    472472          for (int subC=0; subC<prePlaneMax.length; subC++) { 
    473             System.out.print(" " + prePlaneMax[subC]); 
    474           } 
    475         } 
    476         System.out.println(")"); 
    477         System.out.println("\tMin/max populated = " + 
     473            LogTools.print(" " + prePlaneMax[subC]); 
     474          } 
     475        } 
     476        LogTools.println(")"); 
     477        LogTools.println("\tMin/max populated = " + 
    478478          isMinMaxPop + " (initially " + preIsMinMaxPop + ")"); 
    479479      } 
     
    498498    // read format-specific metadata table 
    499499    if (doMeta) { 
    500       System.out.println(); 
    501       System.out.println("Reading" + s + " metadata"); 
     500      LogTools.println(); 
     501      LogTools.println("Reading" + s + " metadata"); 
    502502      Hashtable meta = reader.getMetadata(); 
    503503      String[] keys = (String[]) meta.keySet().toArray(new String[0]); 
    504504      Arrays.sort(keys); 
    505505      for (int i=0; i<keys.length; i++) { 
    506         System.out.print(keys[i] + ": "); 
    507         System.out.println(reader.getMetadataValue(keys[i])); 
     506        LogTools.print(keys[i] + ": "); 
     507        LogTools.println(reader.getMetadataValue(keys[i])); 
    508508      } 
    509509    } 
     
    511511    // output OME-XML 
    512512    if (omexml) { 
    513       System.out.println(); 
    514       System.out.println("Generating OME-XML"); 
     513      LogTools.println(); 
     514      LogTools.println("Generating OME-XML"); 
    515515      MetadataStore ms = reader.getMetadataStore(); 
    516516 
     
    522522          Method m = ms.getClass().getMethod("dumpXML", (Class[]) null); 
    523523          String xml = (String) m.invoke(ms, (Object[]) null); 
    524           System.out.println(FormatTools.indentXML(xml)); 
     524          LogTools.println(FormatTools.indentXML(xml)); 
    525525        } 
    526526        catch (Throwable t) { 
    527           System.out.println("Error generating OME-XML:"); 
    528           t.printStackTrace(); 
     527          LogTools.println("Error generating OME-XML:"); 
     528          LogTools.trace(t); 
    529529        } 
    530530      } 
    531531      else { 
    532         System.out.println("OME-Java library not found; no OME-XML available"); 
     532        LogTools.println("OME-Java library not found; no OME-XML available"); 
    533533      } 
    534534    } 
     
    546546        if (args[i].startsWith("-") && args.length > 1) { 
    547547          if (args[i].equals("-debug")) FormatHandler.setDebug(true); 
    548           else System.out.println("Ignoring unknown command flag: " + args[i]); 
     548          else LogTools.println("Ignoring unknown command flag: " + args[i]); 
    549549        } 
    550550        else { 
    551551          if (in == null) in = args[i]; 
    552552          else if (out == null) out = args[i]; 
    553           else System.out.println("Ignoring unknown argument: " + args[i]); 
     553          else LogTools.println("Ignoring unknown argument: " + args[i]); 
    554554        } 
    555555      } 
    556556    } 
    557557    if (FormatHandler.debug) { 
    558       System.out.println("Debugging at level " + FormatHandler.debugLevel); 
     558      LogTools.println("Debugging at level " + FormatHandler.debugLevel); 
    559559    } 
    560560    String className = writer.getClass().getName(); 
    561561    if (in == null || out == null) { 
    562       System.out.println("To convert a file to " + writer.getFormat() + 
     562      LogTools.println("To convert a file to " + writer.getFormat() + 
    563563        " format, run:"); 
    564       System.out.println("  java " + className + " [-debug] in_file out_file"); 
     564      LogTools.println("  java " + className + " [-debug] in_file out_file"); 
    565565      return false; 
    566566    } 
    567567 
    568568    long start = System.currentTimeMillis(); 
    569     System.out.print(in + " "); 
     569    LogTools.print(in + " "); 
    570570    ImageReader reader = new ImageReader(); 
    571571    reader.setId(in); 
    572     System.out.print("[" + reader.getFormat() + "] -> " + out + " "); 
     572    LogTools.print("[" + reader.getFormat() + "] -> " + out + " "); 
    573573    writer.setId(out); 
    574     System.out.print("[" + writer.getFormat() + "] "); 
     574    LogTools.print("[" + writer.getFormat() + "] "); 
    575575    long mid = System.currentTimeMillis(); 
    576576 
     
    583583      writer.saveImage(image, i == num - 1); 
    584584      long e = System.currentTimeMillis(); 
    585       System.out.print("."); 
     585      LogTools.print("."); 
    586586      read += m - s; 
    587587      write += e - m; 
    588588    } 
    589589    long end = System.currentTimeMillis(); 
    590     System.out.println(" [done]"); 
     590    LogTools.println(" [done]"); 
    591591 
    592592    // output timing results 
     
    595595    float readAvg = (float) read / num; 
    596596    float writeAvg = (float) write / num; 
    597     System.out.println(sec + "s elapsed (" + 
     597    LogTools.println(sec + "s elapsed (" + 
    598598      readAvg + "+" + writeAvg + "ms per image, " + initial + "ms overhead)"); 
    599599 
     
    612612 
    613613    public void statusUpdated(StatusEvent e) { 
    614       if (verbose) System.out.println("\t" + e.getStatusMessage()); 
     614      if (verbose) LogTools.println("\t" + e.getStatusMessage()); 
    615615      else if (next) { 
    616         System.out.print(";"); 
     616        LogTools.print(";"); 
    617617        next = false; 
    618618      } 
  • trunk/loci/formats/FilePattern.java

    r2204 r2857  
    547547      // test file pattern detection based on the given file on disk 
    548548      Location file = new Location(args[0]); 
    549       System.out.println("File = " + file.getAbsoluteFile()); 
     549      LogTools.println("File = " + file.getAbsoluteFile()); 
    550550      pat = findPattern(file); 
    551551    } 
     
    568568      pat = findPattern(nameList[1], null, nameList); 
    569569    } 
    570     if (pat == null) System.out.println("No pattern found."); 
     570    if (pat == null) LogTools.println("No pattern found."); 
    571571    else { 
    572       System.out.println("Pattern = " + pat); 
     572      LogTools.println("Pattern = " + pat); 
    573573      FilePattern fp = new FilePattern(pat); 
    574574      if (fp.isValid()) { 
    575         System.out.println("Pattern is valid."); 
    576         System.out.println("Files:"); 
     575        LogTools.println("Pattern is valid."); 
     576        LogTools.println("Files:"); 
    577577        String[] ids = fp.getFiles(); 
    578578        for (int i=0; i<ids.length; i++) { 
    579           System.out.println("  #" + i + ": " + ids[i]); 
    580         } 
    581       } 
    582       else System.out.println("Pattern is invalid: " + fp.getErrorMessage()); 
     579          LogTools.println("  #" + i + ": " + ids[i]); 
     580        } 
     581      } 
     582      else LogTools.println("Pattern is invalid: " + fp.getErrorMessage()); 
    583583    } 
    584584  } 
  • trunk/loci/formats/FileStitcher.java

    r2796 r2857  
    538538          } 
    539539          catch (FormatException exc) { 
    540             exc.printStackTrace(); 
     540            LogTools.trace(exc); 
    541541            return null; 
    542542          } 
    543543          catch (IOException exc) { 
    544             exc.printStackTrace(); 
     544            LogTools.trace(exc); 
    545545            return null; 
    546546          } 
     
    673673  protected void initFile(String id) throws FormatException, IOException { 
    674674    if (FormatHandler.debug) { 
    675       System.out.println("calling FileStitcher.initFile(" + id + ")"); 
     675      LogTools.println("calling FileStitcher.initFile(" + id + ")"); 
    676676    } 
    677677 
     
    726726        readers[i] = (IFormatReader) r; 
    727727      } 
    728       catch (InstantiationException exc) { exc.printStackTrace(); } 
    729       catch (IllegalAccessException exc) { exc.printStackTrace(); } 
    730       catch (NoSuchMethodException exc) { exc.printStackTrace(); } 
    731       catch (InvocationTargetException exc) { exc.printStackTrace(); } 
     728      catch (InstantiationException exc) { LogTools.trace(exc); } 
     729      catch (IllegalAccessException exc) { LogTools.trace(exc); } 
     730      catch (NoSuchMethodException exc) { LogTools.trace(exc); } 
     731      catch (InvocationTargetException exc) { LogTools.trace(exc); } 
    732732    } 
    733733 
  • trunk/loci/formats/FormatHandler.java

    r2771 r2857  
    2525package loci.formats; 
    2626 
    27 import java.io.IOException; 
     27import java.io.*; 
    2828import java.util.Vector; 
    2929 
     
    8484  } 
    8585 
    86   /** Issues a debugging statement. */ 
     86  /** Issues a debugging statement. Convenience method for format handlers. */ 
    8787  protected void debug(String s) { 
    88     // NB: could use a logger class or other means of output here, if desired 
    8988    String name = getClass().getName(); 
    9089    String prefix = "loci.formats."; 
     
    9392    } 
    9493    String msg = System.currentTimeMillis() + ": " + name + ": " + s; 
    95     if (debugLevel > 3) trace(msg); 
    96     else System.out.println(msg); 
     94    if (debugLevel > 3) LogTools.trace(msg); 
     95    else LogTools.println(msg); 
    9796  } 
    9897 
    99   /** Issues a stack trace. */ 
    100   protected void trace(String s) { 
    101     new Exception(s).printStackTrace(); 
    102   } 
     98  /** Issues a stack trace. Convenience method for format handlers. */ 
     99  protected void trace(String s) { LogTools.trace(s); } 
     100 
     101  /** Issues a stack trace. Convenience method for format handlers. */ 
     102  protected void trace(Throwable t) { LogTools.trace(t); } 
    103103 
    104104  // -- IFormatHandler API methods -- 
  • trunk/loci/formats/FormatReader.java

    r2806 r2857  
    176176    } 
    177177    catch (Throwable t) { 
    178       System.out.println("Error populating OME-XML"); 
    179       t.printStackTrace(); 
     178      debug("Error populating OME-XML"); 
     179      trace(t); 
    180180    } 
    181181  } 
     
    398398      String s = "setNormalized called with open file."; 
    399399      if (debug && debugLevel >= 2) trace(s); 
    400       else System.err.println("Warning: " + s); 
     400      else LogTools.println("Warning: " + s); 
    401401    } 
    402402    normalizeData = normalize; 
     
    414414      String s = "setMetadataCollected called with open file."; 
    415415      if (debug && debugLevel >= 2) trace(s); 
    416       else System.err.println("Warning: " + s); 
     416      else LogTools.println("Warning: " + s); 
    417417    } 
    418418    collectMetadata = collect; 
     
    471471      String s = "setMetadataFiltered called with open file."; 
    472472      if (debug && debugLevel >= 2) trace(s); 
    473       else System.err.println("Warning: " + s); 
     473      else LogTools.println("Warning: " + s); 
    474474    } 
    475475    filterMetadata = filter; 
     
    487487      String s = "setMetadataStore called with open file."; 
    488488      if (debug && debugLevel >= 2) trace(s); 
    489       else System.err.println("Warning: " + s); 
     489      else LogTools.println("Warning: " + s); 
    490490    } 
    491491    metadataStore = store; 
  • trunk/loci/formats/ImageReader.java

    r2800 r2857  
    5252      } 
    5353      catch (IOException exc) { 
    54         exc.printStackTrace(); 
    5554        defaultClasses = new ClassList(IFormatReader.class); 
     55        LogTools.trace(exc); 
    5656      } 
    5757    } 
     
    9999      catch (InstantiationException exc) { } 
    100100      if (reader == null) { 
    101         System.err.println("Error: " + c[i].getName() + 
     101        LogTools.println("Error: " + c[i].getName() + 
    102102          " cannot be instantiated."); 
    103103        continue; 
  • trunk/loci/formats/ImageTools.java

    r2800 r2857  
    18971897    PixelGrabber pg = new PixelGrabber(image, 0, 0, w, h, pixels, 0, w); 
    18981898    try { pg.grabPixels(); } 
    1899     catch (InterruptedException exc) { exc.printStackTrace(); } 
     1899    catch (InterruptedException exc) { LogTools.trace(exc); } 
    19001900    BufferedImage result = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); 
    19011901    result.setRGB(0, 0, w, h, pixels, 0, w); 
  • trunk/loci/formats/ImageWriter.java

    r2796 r2857  
    5353      } 
    5454      catch (IOException exc) { 
    55         exc.printStackTrace(); 
    5655        defaultClasses = new ClassList(IFormatWriter.class); 
     56        LogTools.trace(exc); 
    5757      } 
    5858    } 
     
    106106      catch (InstantiationException exc) { } 
    107107      if (writer == null) { 
    108         System.err.println("Error: " + c[i].getName() + 
     108        LogTools.println("Error: " + c[i].getName() + 
    109109          " cannot be instantiated."); 
    110110        continue; 
  • trunk/loci/formats/LegacyQTTools.java

    r2320 r2857  
    7070        }; 
    7171      } 
    72       catch (MalformedURLException exc) { exc.printStackTrace(); } 
     72      catch (MalformedURLException exc) { LogTools.trace(exc); } 
    7373      return paths == null ? null : new URLClassLoader(paths); 
    7474    } 
     
    8484          paths = new URL[] {f.toURL()}; 
    8585        } 
    86         catch (MalformedURLException exc) { exc.printStackTrace(); } 
     86        catch (MalformedURLException exc) { LogTools.trace(exc); } 
    8787        return paths == null ? null : new URLClassLoader(paths); 
    8888      } 
     
    252252    catch (Exception e) { 
    253253      try { r.exec("QTSession.close()"); } 
    254       catch (ReflectException exc) { exc.printStackTrace(); } 
     254      catch (ReflectException exc) { LogTools.trace(exc); } 
    255255      throw new FormatException("PICT extraction failed", e); 
    256256    } 
  • trunk/loci/formats/RandomAccessStream.java

    r2800 r2857  
    710710      { 
    711711        try { files[ndx].close(); } 
    712         catch (IOException e) { e.printStackTrace(); } 
     712        catch (IOException exc) { LogTools.trace(exc); } 
    713713        closed++; 
    714714      } 
  • trunk/loci/formats/ReflectedUniverse.java

    r2178 r2857  
    111111      } 
    112112      catch (NoClassDefFoundError err) { 
    113         if (debug) err.printStackTrace(); 
     113        if (debug) LogTools.trace(err); 
    114114        throw new ReflectException("No such class: " + command, err); 
    115115      } 
    116116      catch (ClassNotFoundException exc) { 
    117         if (debug) exc.printStackTrace(); 
     117        if (debug) LogTools.trace(exc); 
    118118        throw new ReflectException("No such class: " + command, exc); 
    119119      } 
     
    200200      } 
    201201      catch (Exception exc) { 
    202         if (debug) exc.printStackTrace(); 
     202        if (debug) LogTools.trace(exc); 
    203203        throw new ReflectException("Cannot instantiate object", exc); 
    204204      } 
     
    250250      } 
    251251      catch (Exception exc) { 
    252         if (debug) exc.printStackTrace(); 
     252        if (debug) LogTools.trace(exc); 
    253253        throw new ReflectException("Cannot execute method: " + 
    254254          methodName, exc); 
     
    327327      } 
    328328      catch (NoSuchFieldException exc) { 
    329         if (debug) exc.printStackTrace(); 
     329        if (debug) LogTools.trace(exc); 
    330330        throw new ReflectException("No such field: " + varName, exc); 
    331331      } 
     
    335335      } 
    336336      catch (Exception exc) { 
    337         if (debug) exc.printStackTrace(); 
     337        if (debug) LogTools.trace(exc); 
    338338        throw new ReflectException("Cannot get field value: " + varName, exc); 
    339339      } 
  • trunk/loci/formats/TiffTools.java

    r2773 r2857  
    24692469  /** Prints a debugging message with current time. */ 
    24702470  public static void debug(String message) { 
    2471     System.out.println(System.currentTimeMillis() + ": " + message); 
     2471    LogTools.println(System.currentTimeMillis() + ": " + message); 
    24722472  } 
    24732473 
  • trunk/loci/formats/codec/BaseCodec.java

    r2711 r2857  
    2727import java.util.*; 
    2828import loci.formats.FormatException; 
     29import loci.formats.LogTools; 
    2930 
    3031/** 
     
    5455    byte[] testdata = new byte[50000]; 
    5556    Random r = new Random(); 
    56     System.out.println("Testing " + this.getClass().getName()); 
    57     System.out.println("Generating random data"); 
     57    LogTools.println("Testing " + this.getClass().getName()); 
     58    LogTools.println("Generating random data"); 
    5859    r.nextBytes(testdata); 
    59     System.out.println("Compressing data"); 
     60    LogTools.println("Compressing data"); 
    6061    byte[] compressed = compress(testdata, 0, 0, null, null); 
    61     System.out.println("Compressed size: " + compressed.length); 
    62     System.out.println("Decompressing data"); 
     62    LogTools.println("Compressed size: " + compressed.length); 
     63    LogTools.println("Decompressing data"); 
    6364    byte[] decompressed = decompress(compressed); 
    64     System.out.print("Comparing data... "); 
     65    LogTools.print("Comparing data... "); 
    6566    if (testdata.length != decompressed.length) { 
    66       System.out.println("Test data differs in length from uncompressed data"); 
    67       System.out.println("Exiting..."); 
     67      LogTools.println("Test data differs in length from uncompressed data"); 
     68      LogTools.println("Exiting..."); 
    6869      System.exit(-1); 
    6970    } 
     
    7273      for (int i = 0; i < testdata.length; i++) { 
    7374        if (testdata[i] != decompressed[i]) { 
    74           System.out.println("Test data and uncompressed data differs at byte" + 
     75          LogTools.println("Test data and uncompressed data differs at byte" + 
    7576                             i); 
    7677          equalsFlag = false; 
     
    7879      } 
    7980      if (!equalsFlag) { 
    80         System.out.println("Comparison failed. \nExiting..."); 
     81        LogTools.println("Comparison failed. \nExiting..."); 
    8182        System.exit(-1); 
    8283      } 
    8384    } 
    84     System.out.println("Success."); 
    85     System.out.println("Generating 2D byte array test"); 
     85    LogTools.println("Success."); 
     86    LogTools.println("Generating 2D byte array test"); 
    8687    byte[][] twoDtest = new byte[100][500]; 
    8788    for (int i = 0; i < 100; i++) { 
     
    8990    } 
    9091    byte[] twoDcompressed = compress(twoDtest, 0, 0, null, null); 
    91     System.out.print("Comparing compressed data... "); 
     92    LogTools.print("Comparing compressed data... "); 
    9293    if (twoDcompressed.length != compressed.length) { 
    93       System.out.println("1D and 2D compressed data not same length"); 
    94       System.out.println("Exiting..."); 
     94      LogTools.println("1D and 2D compressed data not same length"); 
     95      LogTools.println("Exiting..."); 
    9596      System.exit(-1); 
    9697    } 
     
    9899    for (int i = 0; i < twoDcompressed.length; i++) { 
    99100      if (twoDcompressed[i] != compressed[i]) { 
    100         System.out.println("1D data and 2D compressed data differs at byte" + 
     101        LogTools.println("1D data and 2D compressed data differs at byte" + 
    101102                           i); 
    102103        equalsFlag = false; 
    103104      } 
    104105      if (!equalsFlag) { 
    105         System.out.println("Comparison failed. \nExiting..."); 
     106        LogTools.println("Comparison failed. \nExiting..."); 
    106107        System.exit(-1); 
    107108      } 
    108109    } 
    109     System.out.println("Success."); 
    110     System.out.println("Test complete."); 
     110    LogTools.println("Success."); 
     111    LogTools.println("Test complete."); 
    111112  } 
    112113 
  • trunk/loci/formats/codec/BitBuffer.java

    r2450 r2857  
    2626 
    2727import java.util.Random; // used in main method test 
     28import loci.formats.LogTools; 
    2829 
    2930/** 
     
    165166 
    166167    Random r = new Random(); 
    167     System.out.println("Generating " + trials + " trials."); 
    168     System.out.println("Writing to byte array"); 
     168    LogTools.println("Generating " + trials + " trials."); 
     169    LogTools.println("Writing to byte array"); 
    169170    // we want the trials to be able to be all possible bit lengths. 
    170171    // r.nextInt() by itself is not sufficient... in 50000 trials it would be 
     
    187188    BitBuffer bb = new BitBuffer(bw.toByteArray()); 
    188189    int readint; 
    189     System.out.println("Reading from BitBuffer"); 
     190    LogTools.println("Reading from BitBuffer"); 
    190191    // Randomly skip or read bytes 
    191192    for(int i = 0; i < trials; i++) { 
     
    194195        readint = bb.getBits(len[i]); 
    195196        if(readint != nums[i]) { 
    196           System.out.println("Error at #" + i + ": " + readint + " received, " + 
     197          LogTools.println("Error at #" + i + ": " + readint + " received, " + 
    197198            nums[i] + " expected."); 
    198199        } 
     
    203204    } 
    204205    // Test reading past end of buffer. 
    205     System.out.println("Testing end of buffer"); 
     206    LogTools.println("Testing end of buffer"); 
    206207    bb = new BitBuffer(bw.toByteArray()); 
    207208    // The total length could be mid byte. Add one byte to test. 
     
    209210    int read = bb.getBits(1); 
    210211    if(-1 != read) { 
    211       System.out.println("-1 expected at end of buffer, " + 
     212      LogTools.println("-1 expected at end of buffer, " + 
    212213                         read + " received."); 
    213214    } 
  • trunk/loci/formats/codec/BitWriter.java

    r2450 r2857  
    2626 
    2727import java.util.*; 
     28import loci.formats.LogTools; 
    2829 
    2930/** 
     
    123124    int max = 50000; 
    124125    // randomize values 
    125     System.out.println("Generating random list of " + max + " values"); 
     126    LogTools.println("Generating random list of " + max + " values"); 
    126127    int[] values = new int[max]; 
    127128    int[] bits = new int[max]; 
     
    134135 
    135136    // write values out 
    136     System.out.println("Writing values to byte array"); 
     137    LogTools.println("Writing values to byte array"); 
    137138    BitWriter out = new BitWriter(); 
    138139    for (int i=0; i<values.length; i++) out.write(values[i], bits[i]); 
    139140 
    140141    // read values back in 
    141     System.out.println("Reading values from byte array"); 
     142    LogTools.println("Reading values from byte array"); 
    142143    BitBuffer bb = new BitBuffer(out.toByteArray()); 
    143144    for (int i=0; i<values.length; i++) { 
    144145      int value = bb.getBits(bits[i]); 
    145146      if (value != values[i]) { 
    146         System.out.println("Value #" + i + " does not match (got " + 
     147        LogTools.println("Value #" + i + " does not match (got " + 
    147148          value + "; expected " + values[i] + "; " + bits[i] + " bits)"); 
    148149      } 
     
    151152    // Testing string functionality 
    152153    Random r = new Random(); 
    153     System.out.println("Generating 5000 random bits for String test"); 
     154    LogTools.println("Generating 5000 random bits for String test"); 
    154155    StringBuffer sb = new StringBuffer(5000); 
    155156    for (int i = 0; i < 5000; i++) { 
     
    157158    } 
    158159    out = new BitWriter(); 
    159     System.out.println("Writing values to byte array"); 
     160    LogTools.println("Writing values to byte array"); 
    160161    out.write(sb.toString()); 
    161     System.out.println("Reading values from byte array"); 
     162    LogTools.println("Reading values from byte array"); 
    162163    bb = new BitBuffer(out.toByteArray()); 
    163164    for (int i = 0; i < 5000; i++) { 
     
    165166      int expected = (sb.charAt(i) == '1') ? 1 : 0; 
    166167      if (value != expected) { 
    167         System.out.println("Bit #" + i + " does not match (got " + value + 
     168        LogTools.println("Bit #" + i + " does not match (got " + value + 
    168169          "; expected " + expected + "."); 
    169170      } 
  • trunk/loci/formats/codec/CBZip2InputStream.java

    r2801 r2857  
    5050import java.io.IOException; 
    5151import java.io.InputStream; 
     52import loci.formats.LogTools; 
    5253 
    5354/** 
     
    7576 
    7677    // Just print a message, like the previous versions of this class did 
    77     System.err.println("BZip2 CRC error"); 
     78    LogTools.println("BZip2 CRC error"); 
    7879  } 
    7980 
  • trunk/loci/formats/codec/JPEGCodec.java

    r2601 r2857  
    2828import java.io.*; 
    2929import javax.imageio.ImageIO; 
    30 import loci.formats.FormatException; 
    31 import loci.formats.ImageTools; 
     30import loci.formats.*; 
    3231 
    3332/** 
     
    6867      b = ImageIO.read(new ByteArrayInputStream(input)); 
    6968    } 
    70     catch (IOException e) { 
    71       System.err.println("An I/O Error occurred decompressing image." + 
    72         " Stack dump follows:"); 
    73       e.printStackTrace(); 
     69    catch (IOException exc) { 
     70      LogTools.println( 
     71        "An I/O error occurred decompressing image. Stack dump follows:"); 
     72      LogTools.trace(exc); 
    7473      return null; 
    7574    } 
  • trunk/loci/formats/gui/DataConverter.java

    r2801 r2857  
    319319        } 
    320320      } 
    321       catch (Exception exc) { 
    322         exc.printStackTrace(); 
    323       } 
     321      catch (Exception exc) { LogTools.trace(exc); } 
    324322 
    325323      updateLabels(pattern); 
     
    346344        } 
    347345      } 
    348       catch (Exception exc) { 
    349         exc.printStackTrace(); 
    350       } 
     346      catch (Exception exc) { LogTools.trace(exc); } 
    351347    } 
    352348    else if ("zChoice".equals(cmd)) { 
     
    391387        updateLabels(input.getText()); 
    392388      } 
    393       catch (Exception exc) { 
    394         exc.printStackTrace(); 
    395       } 
     389      catch (Exception exc) { LogTools.trace(exc); } 
    396390    } 
    397391  } 
     
    659653    } 
    660654    catch (Exception exc) { 
    661       exc.printStackTrace(); 
     655      LogTools.trace(exc); 
    662656      String err = exc.getMessage(); 
    663657      if (err == null) err = exc.getClass().getName(); 
     
    716710      includeC.setEnabled(true); 
    717711    } 
    718     catch (Exception exc) { 
    719       exc.printStackTrace(); 
    720     } 
     712    catch (Exception exc) { LogTools.trace(exc); } 
    721713  } 
    722714 
  • trunk/loci/formats/gui/ImageViewer.java

    r2809 r2857  
    222222    } 
    223223    catch (Exception exc) { 
    224       exc.printStackTrace(); 
     224      LogTools.trace(exc); 
    225225      wait(false); 
    226226      return; 
     
    254254      } 
    255255    } 
    256     catch (Exception exc) { exc.printStackTrace(); } 
     256    catch (Exception exc) { LogTools.trace(exc); } 
    257257    wait(false); 
    258258  } 
     
    270270      //if (reader.isRGB(id)) sizeC = (sizeC + 2) / 3; // adjust for RGB 
    271271    } 
    272     catch (Exception exc) { exc.printStackTrace(); } 
     272    catch (Exception exc) { LogTools.trace(exc); } 
    273273 
    274274    fileSave.setEnabled(true); 
     
    374374        r.exec("new Notes(null, filename)"); 
    375375      } 
    376       catch (ReflectException exc) { exc.printStackTrace(); } 
     376      catch (ReflectException exc) { LogTools.trace(exc); } 
    377377    } 
    378378    else if ("exit".equals(cmd)) dispose(); 
     
    401401      int[] zct = {-1, -1, -1}; 
    402402      try { zct = in.getZCTCoords(ndx); } 
    403       catch (Exception exc) { exc.printStackTrace(); } 
     403      catch (Exception exc) { LogTools.trace(exc); } 
    404404      if (zct[0] >= 0) { 
    405405        zSlider.removeChangeListener(this); 
     
    422422      int ndx = -1; 
    423423      try { ndx = in.getIndex(getZ(), getC(), getT()); } 
    424       catch (Exception exc) { exc.printStackTrace(); } 
     424      catch (Exception exc) { LogTools.trace(exc); } 
    425425      if (ndx >= 0) { 
    426426        nSlider.removeChangeListener(this); 
  • trunk/loci/formats/in/BaseTiffReader.java

    r2800 r2857  
    602602          creationDate = sdf.format(date); 
    603603        } 
    604         catch (Exception ex) { 
     604        catch (Exception exc) { 
    605605          // TODO: eliminate catch-all exception handling 
    606           if (debug) ex.printStackTrace(); 
     606          if (debug) trace(exc); 
    607607          creationDate = null; 
    608608        } 
     
    619619          setLogicalChannel(i); 
    620620        } 
    621         catch (FormatException e) { 
    622           if (debug) e.printStackTrace(); 
     621        catch (FormatException exc) { 
     622          if (debug) trace(exc); 
    623623        } 
    624         catch (IOException e) { 
    625           if (debug) e.printStackTrace(); 
     624        catch (IOException exc) { 
     625          if (debug) trace(exc); 
    626626        } 
    627627      } 
     
    675675      store.setInstrument(null, model, serialNumber, null, null); 
    676676    } 
    677     catch (FormatException exc) { exc.printStackTrace(); } 
     677    catch (FormatException exc) { trace(exc); } 
    678678  } 
    679679 
  • trunk/loci/formats/in/EPSReader.java

    r2844 r2857  
    226226          catch (Exception exc) { 
    227227            // CTR TODO - eliminate catch-all exception handling 
    228             if (debug) exc.printStackTrace(); 
     228            if (debug) trace(exc); 
    229229            core.sizeC[0] = Integer.parseInt(t.nextToken()); 
    230230          } 
  • trunk/loci/formats/in/FlexReader.java

    r2801 r2857  
    163163    int fsize = f.size(); 
    164164    if (debug && (nsize != fsize || nsize != core.imageCount[0])) { 
    165       System.err.println("Warning: mismatch between image count, " + 
     165      LogTools.println("Warning: mismatch between image count, " + 
    166166        "names and factors (count=" + core.imageCount[0] + 
    167167        ", names=" + nsize + ", factors=" + fsize + ")"); 
     
    181181      catch (NumberFormatException exc) { 
    182182        if (debug) { 
    183           System.err.println("Warning: invalid factor #" + i + ": " + factor); 
     183          LogTools.println("Warning: invalid factor #" + i + ": " + factor); 
    184184        } 
    185185      } 
  • trunk/loci/formats/in/GelReader.java

    r2687 r2857  
    7171      addMeta("Data format", fmt == 2 ? "square root" : "linear"); 
    7272    } 
    73     catch (FormatException f) { 
    74       f.printStackTrace(); 
     73    catch (FormatException exc) { 
     74      trace(exc); 
    7575    } 
    7676 
  • trunk/loci/formats/in/IPWReader.java

    r2701 r2857  
    6060    catch (Throwable t) { 
    6161      noPOI = true; 
     62      if (debug) LogTools.trace(t); 
    6263    } 
    6364    return r; 
     
    371372    catch (Throwable t) { 
    372373      noPOI = true; 
    373       if (debug) t.printStackTrace(); 
     374      if (debug) trace(t); 
    374375    } 
    375376  } 
  • trunk/loci/formats/in/LegacyZVIReader.java

    r2802 r2857  
    427427    numT = tSet.size(); 
    428428    if (numZ * numC * numT != blockList.size()) { 
    429       System.err.println("Warning: image counts do not match. " + WHINING); 
     429      LogTools.println("Warning: image counts do not match. " + WHINING); 
    430430    } 
    431431  } 
     
    520520      numChannels = pixelType == 1 ? 3 : 1;  // a total shot in the dark 
    521521      if (bytesPerPixel % numChannels != 0) { 
    522         System.err.println("Warning: incompatible bytesPerPixel (" + 
     522        LogTools.println("Warning: incompatible bytesPerPixel (" + 
    523523          bytesPerPixel + ") and numChannels (" + numChannels + 
    524524          "). Assuming grayscale data. " + WHINING); 
  • trunk/loci/formats/in/LeicaReader.java

    r2800 r2857  
    235235    } 
    236236    catch (IOException exc) { 
    237       if (debug) exc.printStackTrace(); 
     237      if (debug) trace(exc); 
    238238    } 
    239239    catch (ClassCastException exc) { 
    240       if (debug) exc.printStackTrace(); 
     240      if (debug) trace(exc); 
    241241    } 
    242242    return false; 
  • trunk/loci/formats/in/MDBParser.java

    r2601 r2857  
    6060      r.exec("import mdbtools.libmdb.mem"); 
    6161    } 
    62     catch (Throwable exc) { 
     62    catch (Throwable t) { 
    6363      noMDB = true; 
    6464    } 
     
    171171      } 
    172172    } 
    173     catch (ReflectException re) { 
    174       re.printStackTrace(); 
     173    catch (ReflectException exc) { 
     174      LogTools.trace(exc); 
    175175    } 
    176176  } 
  • trunk/loci/formats/in/MetamorphReader.java

    r2802 r2857  
    392392      ifds = tempIFDs; 
    393393    } 
    394     catch (NullPointerException n) { n.printStackTrace(); } 
    395     catch (IOException io) { io.printStackTrace(); } 
    396     catch (FormatException e) { e.printStackTrace(); } 
     394    catch (NullPointerException exc) { trace(exc); } 
     395    catch (IOException exc) { trace(exc); } 
     396    catch (FormatException exc) { trace(exc); } 
    397397 
    398398    try { 
     
    400400    } 
    401401    catch (FormatException exc) { 
    402       if (debug) exc.printStackTrace(); 
     402      if (debug) trace(exc); 
    403403    } 
    404404    catch (IOException exc) { 
    405       if (debug) exc.printStackTrace(); 
     405      if (debug) trace(exc); 
    406406    } 
    407407 
     
    458458    } 
    459459    catch (FormatException exc) { 
    460       if (debug) exc.printStackTrace(); 
     460      if (debug) trace(exc); 
    461461    } 
    462462  } 
  • trunk/loci/formats/in/ND2Reader.java

    r2842 r2857  
    7575      } 
    7676      catch (ClassNotFoundException exc) { 
    77         if (debug) exc.printStackTrace(); 
     77        if (debug) LogTools.trace(exc); 
    7878        noJ2k = true; 
    7979      } 
    8080      catch (NoClassDefFoundError err) { 
    81         if (debug) err.printStackTrace(); 
     81        if (debug) LogTools.trace(err); 
    8282        noJ2k = true; 
    8383      } 
     
    103103      ru.exec("j2kReader = new J2KImageReader(j2kSpi)"); 
    104104    } 
    105     catch (Throwable exc) { 
    106       if (debug) exc.printStackTrace(); 
     105    catch (Throwable t) { 
    107106      noJ2k = true; 
     107      if (debug) LogTools.trace(t); 
    108108    } 
    109109    return ru; 
  • trunk/loci/formats/in/NikonReader.java

    r2687 r2857  
    236236      } 
    237237    } 
    238     catch (IOException e) { 
    239       if (debug) e.printStackTrace(); 
     238    catch (IOException exc) { 
     239      if (debug) trace(exc); 
    240240    } 
    241241  } 
     
    260260      offset = TiffTools.getIFDIntValue(ifds[0], 330, false, 0); 
    261261    } 
    262     catch (Exception e) { 
     262    catch (Exception exc) { 
    263263      // CTR TODO - eliminate catch-all exception handling 
    264       if (debug) e.printStackTrace(); 
     264      if (debug) trace(exc); 
    265265      long[] array = TiffTools.getIFDLongArray(ifds[0], 330, false); 
    266266      offset = (int) array[array.length - 1]; 
  • trunk/loci/formats/in/OIBReader.java

    r2701 r2857  
    440440      initMetadata(); 
    441441    } 
    442     catch (FormatException e) { 
    443       if (debug) e.printStackTrace(); 
    444     } 
    445     catch (IOException e) { 
    446       if (debug) e.printStackTrace(); 
     442    catch (FormatException exc) { 
     443      if (debug) trace(exc); 
     444    } 
     445    catch (IOException exc) { 
     446      if (debug) trace(exc); 
    447447    } 
    448448  } 
  • trunk/loci/formats/in/OMEXMLReader.java

    r2782 r2857  
    5656    catch (Throwable t) { 
    5757      noOME = true; 
     58      if (debug) LogTools.trace(t); 
    5859    } 
    5960  } 
  • trunk/loci/formats/in/OpenlabReader.java

    r2701 r2857  
    146146        } 
    147147      } 
    148       catch (Exception e) { 
     148      catch (Exception exc) { 
    149149        // CTR TODO - eliminate catch-all exception handling 
    150         if (debug) e.printStackTrace(); 
     150        if (debug) trace(exc); 
    151151 
    152152        b = null; 
     
    238238      b = lzoc.decompress(c); 
    239239      if (b.length != size) { 
    240         System.err.println("LZOCodec failed to predict image size"); 
    241         System.err.println(size + " expected, got " + b.length + 
     240        LogTools.println("LZOCodec failed to predict image size"); 
     241        LogTools.println(size + " expected, got " + b.length + 
    242242          ". The image displayed may not be correct."); 
    243243      } 
     
    324324        in.read(b); 
    325325      } 
    326       catch (IOException e) { 
    327         if (debug) e.printStackTrace(); 
     326      catch (IOException exc) { 
     327        if (debug) trace(exc); 
    328328        return false; 
    329329      } 
     
    387387        nextTag = readTagHeader(); 
    388388      } 
    389       catch (IOException e) { 
    390         if (debug) e.printStackTrace(); 
     389      catch (IOException exc) { 
     390        if (debug) trace(exc); 
    391391 
    392392        if (in.getFilePointer() >= in.length()) break; 
    393         else throw new FormatException(e.getMessage()); 
     393        else throw new FormatException(exc.getMessage()); 
    394394      } 
    395395 
     
    501501        in.seek(nextTag); 
    502502      } 
    503       catch (Exception e) { 
     503      catch (Exception exc) { 
    504504        // CTR TODO - eliminate catch-all exception handling 
    505         if (debug) e.printStackTrace(); 
     505        if (debug) trace(exc); 
    506506        in.seek(nextTag); 
    507507      } 
  • trunk/loci/formats/in/PerkinElmerReader.java

    r2802 r2857  
    279279            filesPt++; 
    280280          } 
    281           catch (NumberFormatException f) { 
    282             if (debug) f.printStackTrace(); 
     281          catch (NumberFormatException exc) { 
     282            if (debug) trace(exc); 
    283283          } 
    284284        } 
     
    492492      catch (Throwable th) { 
    493493        // CTR TODO - eliminate catch-all exception handling 
    494         if (debug) th.printStackTrace(); 
     494        if (debug) trace(th); 
    495495      } 
    496496 
     
    646646        originZ == null ? null : new Float(originZ), null); 
    647647    } 
    648     catch (NumberFormatException e) { 
    649       if (debug) e.printStackTrace(); 
     648    catch (NumberFormatException exc) { 
     649      if (debug) trace(exc); 
    650650    } 
    651651 
  • trunk/loci/formats/in/PictReader.java

    r2701 r2857  
    142142      while (driveDecoder()) { } 
    143143    } 
    144     catch (FormatException e) { 
    145       e.printStackTrace(); 
     144    catch (FormatException exc) { 
     145      trace(exc); 
    146146      return ImageTools.makeBuffered(qtTools.pictToImage(pix)); 
    147147    } 
  • trunk/loci/formats/in/QTReader.java

    r2800 r2857  
    357357      parse(0, 0, in.length()); 
    358358    } 
    359     catch (Exception e) { 
    360       if (debug) e.printStackTrace(); 
     359    catch (Exception exc) { 
     360      if (debug) trace(exc); 
    361361      useLegacy = true; 
    362362      legacy = createLegacyReader(); 
     
    537537 
    538538      if (atomSize < 0) { 
    539         System.err.println("QTReader: invalid atom size: " + atomSize); 
     539        LogTools.println("QTReader: invalid atom size: " + atomSize); 
    540540      } 
    541541 
     
    605605              inf.inflate(output); 
    606606            } 
    607             catch (DataFormatException dfe) { 
    608               if (debug) dfe.printStackTrace(); 
     607            catch (DataFormatException exc) { 
     608              if (debug) trace(exc); 
    609609              throw new FormatException("Compressed header not supported."); 
    610610            } 
  • trunk/loci/formats/in/ZeissLSMReader.java

    r2701 r2857  
    468468      } 
    469469    } 
    470     catch (FormatException e) { 
    471       if (debug) e.printStackTrace(); 
    472     } 
    473     catch (IOException e) { 
    474       if (debug) e.printStackTrace(); 
     470    catch (FormatException exc) { 
     471      if (debug) trace(exc); 
     472    } 
     473    catch (IOException exc) { 
     474      if (debug) trace(exc); 
    475475    } 
    476476 
     
    497497            dirList[i])).getAbsolutePath(), metadata); 
    498498        } 
    499         catch (FormatException f) { 
    500           if (debug) f.printStackTrace(); 
     499        catch (FormatException exc) { 
     500          if (debug) trace(exc); 
    501501        } 
    502502        i = dirList.length; 
     
    654654      } 
    655655    } 
    656     catch (ArithmeticException e) { 
    657       if (debug) e.printStackTrace(); 
     656    catch (ArithmeticException exc) { 
     657      if (debug) trace(exc); 
    658658    } 
    659659  } 
  • trunk/loci/formats/in/ZeissZVIReader.java

    r2802 r2857  
    6161    catch (Throwable t) { 
    6262      noPOI = true; 
     63      if (debug) LogTools.trace(t); 
    6364    } 
    6465    return r; 
     
    328329      } 
    329330    } 
    330     catch (ReflectException e) { 
     331    catch (ReflectException exc) { 
    331332      needLegacy = true; 
    332       if (debug) e.printStackTrace(); 
     333      if (debug) trace(exc); 
    333334      initFile(id); 
    334335    } 
     
    337338      initMetadata(); 
    338339    } 
    339     catch (FormatException e) { 
    340       if (debug) e.printStackTrace(); 
     340    catch (FormatException exc) { 
     341      if (debug) trace(exc); 
    341342    } 
    342     catch (IOException e) { 
    343       if (debug) e.printStackTrace(); 
     343    catch (IOException exc) { 
     344      if (debug) trace(exc); 
    344345    } 
    345346  } 
     
    422423          r.exec("dis.read(data)"); 
    423424        } 
    424         catch (ReflectException e) { 
    425           if (debug) e.printStackTrace(); 
     425        catch (ReflectException exc) { 
     426          if (debug) trace(exc); 
    426427        } 
    427428 
  • trunk/loci/formats/ome/OMEReader.java

    r2838 r2857  
    153153      thumb = pf.getThumbnail(pixels); 
    154154    } 
    155     catch (ImageServerException e) { 
    156       if (debug) e.printStackTrace(); 
     155    catch (ImageServerException exc) { 
     156      if (debug) trace(exc); 
    157157    } 
    158158 
  • trunk/loci/formats/ome/OMEWriter.java

    r2838 r2857  
    367367          } 
    368368          else { 
    369             System.err.println("Error: unknown flag: "+ param); 
    370             System.err.println(); 
     369            LogTools.println("Error: unknown flag: "+ param); 
     370            LogTools.println(); 
    371371            doUsage = true; 
    372372            break; 
     
    375375        catch (ArrayIndexOutOfBoundsException exc) { 
    376376          if (i == args.length - 1) { 
    377             System.err.println("Error: flag " + param + 
     377            LogTools.println("Error: flag " + param + 
    378378              " must be followed by a parameter value."); 
    379             System.err.println(); 
     379            LogTools.println(); 
    380380            doUsage = true; 
    381381            break; 
     
    387387        if (id == null) id = args[i]; 
    388388        else { 
    389           System.err.println("Error: unknown argument: " + args[i]); 
    390           System.err.println(); 
     389          LogTools.println("Error: unknown argument: " + args[i]); 
     390          LogTools.println(); 
    391391        } 
    392392      } 
     
    395395    if (id == null) doUsage = true; 
    396396    if (doUsage) { 
    397       System.err.println("Usage: omeul [-s server.address] " + 
     397      LogTools.println("Usage: omeul [-s server.address] " + 
    398398        "[-u username] [-p password] filename"); 
    399       System.err.println(); 
     399      LogTools.println(); 
    400400      System.exit(1); 
    401401    } 
     
    404404    BufferedReader cin = new BufferedReader(new InputStreamReader(System.in)); 
    405405    if (server == null) { 
    406       System.out.print("Server address? "); 
     406      LogTools.print("Server address? "); 
    407407      try { server = cin.readLine(); } 
    408408      catch (IOException exc) { } 
    409409    } 
    410410    if (user == null) { 
    411       System.out.print("Username? "); 
     411      LogTools.print("Username? "); 
    412412      try { user = cin.readLine(); } 
    413413      catch (IOException exc) { } 
    414414    } 
    415415    if (pass == null) { 
    416       System.out.print("Password? "); 
     416      LogTools.print("Password? "); 
    417417      try { pass = cin.readLine(); } 
    418418      catch (IOException exc) { } 
     
    420420 
    421421    if (server == null || user == null || pass == null) { 
    422       System.err.println("Error: could not obtain server login information"); 
     422      LogTools.println("Error: could not obtain server login information"); 
    423423      System.exit(2); 
    424424    } 
    425     System.out.println("Using server " + server + " as user " + user); 
     425    LogTools.println("Using server " + server + " as user " + user); 
    426426 
    427427    // create image uploader 
     
    429429    uploader.addStatusListener(new StatusListener() { 
    430430      public void statusUpdated(StatusEvent e) { 
    431         System.out.println(e.getStatusMessage()); 
     431        LogTools.println(e.getStatusMessage()); 
    432432      } 
    433433    }); 
  • trunk/loci/formats/ome/OMEXMLMetadataStore.java

    r2830 r2857  
    3333import javax.xml.parsers.ParserConfigurationException; 
    3434import javax.xml.transform.TransformerException; 
    35 import loci.formats.FormatTools; 
    36 import loci.formats.MetadataStore; 
     35import loci.formats.*; 
    3736import org.openmicroscopy.xml.*; 
    3837import org.openmicroscopy.xml.st.*; 
     
    7877  public void createRoot(String xml) { 
    7978    try { root = xml == null ? new OMENode() : new OMENode(xml); } 
    80     catch (TransformerException exc) { exc.printStackTrace(); } 
    81     catch (SAXException exc) { exc.printStackTrace(); } 
    82     catch (ParserConfigurationException exc) { exc.printStackTrace(); } 
    83     catch (IOException exc) { exc.printStackTrace(); } 
     79    catch (TransformerException exc) { LogTools.trace(exc); } 
     80    catch (SAXException exc) { LogTools.trace(exc); } 
     81    catch (ParserConfigurationException exc) { LogTools.trace(exc); } 
     82    catch (IOException exc) { LogTools.trace(exc); } 
    8483  } 
    8584 
     
    9089  public String dumpXML() { 
    9190    try { return root == null ? null : root.writeOME(false); } 
    92     catch (TransformerException exc) { exc.printStackTrace(); } 
    93     catch (SAXException exc) { exc.printStackTrace(); } 
    94     catch (ParserConfigurationException exc) { exc.printStackTrace(); } 
    95     catch (IOException exc) { exc.printStackTrace(); } 
     91    catch (TransformerException exc) { LogTools.trace(exc); } 
     92    catch (SAXException exc) { LogTools.trace(exc); } 
     93    catch (ParserConfigurationException exc) { LogTools.trace(exc); } 
     94    catch (IOException exc) { LogTools.trace(exc); } 
    9695    return null; 
    9796  } 
     
    11221121      return (OMEXMLNode) con.newInstance(new Object[] {base}); 
    11231122    } 
    1124     catch (Exception exc) { exc.printStackTrace(); } 
     1123    catch (Exception exc) { LogTools.trace(exc); } 
    11251124    return null; 
    11261125  } 
     
    11561155  private void warn(String msg) { 
    11571156    //log.warn(msg); 
    1158     System.err.println(msg); 
     1157    LogTools.println(msg); 
    11591158  } 
    11601159 
  • trunk/loci/formats/out/LegacyQTWriter.java

    r2687 r2857  
    176176      } 
    177177      catch (Exception e) { 
    178         e.printStackTrace(); 
     178        trace(e); 
    179179        throw new FormatException("Legacy QuickTime writer failed."); 
    180180      } 
     
    251251    } 
    252252    catch (Exception e) { 
    253       e.printStackTrace(); 
     253      trace(e); 
    254254      throw new FormatException("Legacy QuickTime writer failed."); 
    255255    } 
     
    267267      } 
    268268      catch (Exception e) { 
    269         e.printStackTrace(); 
     269        trace(e); 
    270270        throw new FormatException("Legacy QuickTime writer failed."); 
    271271      } 
  • trunk/loci/formats/out/TiffWriter.java

    r2687 r2857  
    143143            xml.writeOME(true)); 
    144144        } 
    145         catch (Exception e) { 
    146           e.printStackTrace(); 
    147         } 
     145        catch (Exception e) { trace(e); } 
    148146      } 
    149147      else { 
  • trunk/loci/formats/test/ImageTester.java

    r2620 r2857  
    3131import javax.swing.*; 
    3232import loci.formats.ImageTools; 
     33import loci.formats.LogTools; 
    3334 
    3435/** 
     
    101102    int w = (screen.width - wpad) / chan.length; 
    102103    int h = (screen.height - hpad) / 6; //9; 
    103     System.out.println("Using images of size " + w + " x " + h); 
     104    LogTools.println("Using images of size " + w + " x " + h); 
    104105    int size = w * h; 
    105106    BufferedImage[] bimg1 = new BufferedImage[chan.length]; 
     
    117118    for (int q=0; q<chan.length; q++) { 
    118119      int c = chan[q]; 
    119       System.out.println("Building c=" + c + " images"); 
     120      LogTools.println("Building c=" + c + " images"); 
    120121      byte[][] bdata1 = new byte[c][size]; 
    121122      byte[] bdata2 = new byte[c * size]; 
     
    165166    } 
    166167 
    167     System.out.println("Rows are: byte[][], byte[] (interleaved), " + 
     168    LogTools.println("Rows are: byte[][], byte[] (interleaved), " + 
    168169      "byte[] (sequential)"); 
    169     System.out.println("  short[][], short[] (interleaved), " + 
     170    LogTools.println("  short[][], short[] (interleaved), " + 
    170171      "short[] (sequential)"); 
    171 //    System.out.println("  int[][], int[] (interleaved), int[] (sequential)"); 
    172     System.out.print("Columns are:"); 
     172//    LogTools.println("  int[][], int[] (interleaved), int[] (sequential)"); 
     173    LogTools.print("Columns are:"); 
    173174    for (int q=0; q<chan.length; q++) { 
    174       if (q > 0) System.out.print(","); 
    175       System.out.print(" c=" + chan[q]); 
     175      if (q > 0) LogTools.print(","); 
     176      LogTools.print(" c=" + chan[q]); 
    176177    } 
    177     System.out.println(); 
     178    LogTools.println(); 
    178179 
    179180    JFrame frame = new JFrame("ImageTester"); 
  • trunk/loci/formats/test/ReaderTest.java

    r2673 r2857  
    148148      averagePlaneAccess = ((float) (l2 - l1)) / planesRead; 
    149149    } 
    150     catch (Exception e) { 
    151       if (FormatHandler.debug) e.printStackTrace(); 
     150    catch (Exception exc) { 
     151      if (FormatHandler.debug) LogTools.trace(exc); 
    152152      success = false; 
    153153    } 
     
    195195      } 
    196196    } 
    197     catch (Exception e) { 
    198       if (FormatHandler.debug) e.printStackTrace(); 
     197    catch (Exception exc) { 
     198      if (FormatHandler.debug) LogTools.trace(exc); 
    199199      success = false; 
    200200    } 
     
    237237      } 
    238238    } 
    239     catch (Exception e) { 
    240       if (FormatHandler.debug) e.printStackTrace(); 
     239    catch (Exception exc) { 
     240      if (FormatHandler.debug) LogTools.trace(exc); 
    241241      success = false; 
    242242    } 
     
    273273      } 
    274274    } 
    275     catch (Exception e) { 
    276       if (FormatHandler.debug) e.printStackTrace(); 
     275    catch (Exception exc) { 
     276      if (FormatHandler.debug) LogTools.trace(exc); 
    277277      success = false; 
    278278    } 
     
    301301      } 
    302302    } 
    303     catch (Exception e) { 
    304       if (FormatHandler.debug) e.printStackTrace(); 
     303    catch (Exception exc) { 
     304      if (FormatHandler.debug) LogTools.trace(exc); 
    305305      success = false; 
    306306    } 
     
    361361      } 
    362362    } 
    363     catch (Exception e) { 
    364       if (FormatHandler.debug) e.printStackTrace(); 
     363    catch (Exception exc) { 
     364      if (FormatHandler.debug) LogTools.trace(exc); 
    365365      success = false; 
    366366    } 
     
    381381      reader.setId(id); 
    382382    } 
    383     catch (Exception e) { 
     383    catch (Exception exc) { 
    384384      writeLog(id + " failed consistent metadata test"); 
    385       if (FormatHandler.debug) e.printStackTrace(); 
     385      if (FormatHandler.debug) LogTools.trace(exc); 
    386386      assertTrue(false); 
    387387    } 
     
    439439        w.close(); 
    440440      } 
    441       catch (Exception e) { 
    442         if (FormatHandler.debug) e.printStackTrace(); 
     441      catch (Exception exc) { 
     442        if (FormatHandler.debug) LogTools.trace(exc); 
    443443 
    444444        configLine = new StringBuffer(); 
     
    453453          w.close(); 
    454454        } 
    455         catch (IOException exc) { 
    456           if (FormatHandler.debug) exc.printStackTrace(); 
     455        catch (IOException exc2) { 
     456          if (FormatHandler.debug) LogTools.trace(exc2); 
    457457          success = false; 
    458458        } 
     
    468468        } 
    469469      } 
    470       catch (Exception e) { 
    471         if (FormatHandler.debug) e.printStackTrace(); 
     470      catch (Exception exc) { 
     471        if (FormatHandler.debug) LogTools.trace(exc); 
    472472        success = false; 
    473473      } 
     
    533533          } 
    534534        } 
    535         catch (Exception e) { 
    536           if (FormatHandler.debug) e.printStackTrace(); 
     535        catch (Exception exc) { 
     536          if (FormatHandler.debug) LogTools.trace(exc); 
    537537          success = false; 
    538538        } 
     
    602602      assertTrue(true); 
    603603    } 
    604     catch (Exception e) { 
    605       if (FormatHandler.debug) e.printStackTrace(); 
     604    catch (Exception exc) { 
     605      if (FormatHandler.debug) LogTools.trace(exc); 
    606606      writeLog(id + " failed sane used files test"); 
    607607    } 
     
    621621      assertTrue(xml != null); 
    622622    } 
    623     catch (Exception e) { 
     623    catch (Exception exc) { 
    624624      writeLog(id + " failed OME-XML validation"); 
    625       e.printStackTrace(); 
     625      LogTools.trace(exc); 
    626626      assertTrue(false); 
    627627    } 
     
    643643      reader.close(); 
    644644    } 
    645     catch (FormatException fe) { 
    646       if (FormatHandler.debug) fe.printStackTrace(); 
    647     } 
    648     catch (IOException io) { 
    649       if (FormatHandler.debug) io.printStackTrace(); 
     645    catch (FormatException exc) { 
     646      if (FormatHandler.debug) LogTools.trace(exc); 
     647    } 
     648    catch (IOException exc) { 
     649      if (FormatHandler.debug) LogTools.trace(exc); 
    650650    } 
    651651  } 
     
    694694        if (!config.isParsed(s)) config.addFile(s); 
    695695      } 
    696       catch (IOException e) { 
    697         if (FormatHandler.debug) e.printStackTrace(); 
     696      catch (IOException exc) { 
     697        if (FormatHandler.debug) LogTools.trace(exc); 
    698698      } 
    699699    } 
     
    719719 
    720720    if (subs == null) { 
    721       System.out.println("Invalid directory: " + root); 
     721      LogTools.println("Invalid directory: " + root); 
    722722      return; 
    723723    } 
     
    764764        logFile.flush(); 
    765765      } 
    766       catch (IOException io) { 
    767         if (FormatHandler.debug) io.printStackTrace(); 
     766      catch (IOException exc) { 
     767        if (FormatHandler.debug) LogTools.trace(exc); 
    768768      } 
    769769    } 
     
    773773    } 
    774774    catch (IOException exc) { 
    775       if (FormatHandler.debug) exc.printStackTrace(); 
    776     } 
    777   } 
    778  
    779   public static void debug(String s) { System.out.println(s); } 
     775      if (FormatHandler.debug) LogTools.trace(exc); 
     776    } 
     777  } 
     778 
     779  public static void debug(String s) { LogTools.println(s); } 
    780780 
    781781  // -- Main method -- 
     
    794794    Vector files = new Vector(); 
    795795    if (args == null || args.length == 0) { 
    796       System.out.println( 
     796      LogTools.println( 
    797797        "Please specify root folder to search for data files."); 
    798798      System.exit(1); 
    799799    } 
    800     System.out.print("Building file list..."); 
    801     if (FormatHandler.debug) System.out.println(); 
     800    LogTools.print("Building file list..."); 
     801    if (FormatHandler.debug) LogTools.println(); 
    802802    getFiles(new Location(args[0]).getAbsolutePath(), files); 
    803     System.out.println(files.size() + " found."); 
     803    LogTools.println(files.size() + " found."); 
    804804    while (files.size() > 0) { 
    805805      String id = (String) files.elementAt(0); 
    806806      String pattern = FilePattern.findPattern(new Location(id)); 
    807807      if (pattern == null) pattern = id; 
    808       System.out.println("Testing " + pattern); 
     808      LogTools.println("Testing " + pattern); 
    809809      TestResult result = new TestResult(); 
    810810      TestSuite suite = suite(id); 
     
    813813      int failed = result.failureCount(); 
    814814      float failPercent = (float) (100 * ((double) failed / (double) total)); 
    815       System.out.println(id + " - " + failed + " failures in " + 
     815      LogTools.println(id + " - " + failed + " failures in " + 
    816816        total + " tests (" + failPercent + "% failed)"); 
    817817 
     
    820820      String[] used = test.getUsedFiles(); 
    821821      if (used == null) { 
    822         System.out.println("Warning: used files list is null for " + id); 
     822        LogTools.println("Warning: used files list is null for " + id); 
    823823 
    824824        used = new FilePattern(pattern).getFiles(); 
    825825        if (used != null) { 
    826826          for (int i=0; i<used.length; i++) { 
    827             if (FormatHandler.debug) System.out.println("Removing " + used[i]); 
     827            if (FormatHandler.debug) LogTools.println("Removing " + used[i]); 
    828828            files.removeElement(used[i]); 
    829829          } 
     
    833833      else { 
    834834        for (int i=0; i<used.length; i++) { 
    835           if (FormatHandler.debug) System.out.println("Removing " + used[i]); 
     835          if (FormatHandler.debug) LogTools.println("Removing " + used[i]); 
    836836          files.removeElement(used[i]); 
    837837        } 
Note: See TracChangeset for help on using the changeset viewer.