Changeset 5842


Ignore:
Timestamp:
01/27/10 13:11:34 (10 years ago)
Author:
melissa
Message:

Removed loci.common.Log and loci.common.LogTools, in favor of SLF4J logging. Components other than common will likely not compile.

Location:
branches/cleanup
Files:
3 added
3 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • branches/cleanup/components/common/build.properties

    r5841 r5842  
    1010component.jar            = loci-common.jar 
    1111component.version        = 4.1.0 
    12 component.classpath      = ${lib.dir}/testng-5.11-jdk15.jar 
     12component.classpath      = ${lib.dir}/testng-5.11-jdk15.jar:\ 
     13                           ${lib.dir}/slf4j-api-1.5.10.jar:\ 
     14                           ${lib.dir}/slf4j-log4j12-1.5.10.jar:\ 
     15                           ${lib.dir}/log4j-1.2.15.jar 
    1316component.java-version   = 1.5 
    1417component.deprecation    = true 
  • branches/cleanup/components/common/src/loci/common/CBZip2InputStream.java

    r4953 r5842  
    4949import java.io.IOException; 
    5050import java.io.InputStream; 
     51 
     52import org.slf4j.Logger; 
     53import org.slf4j.LoggerFactory; 
    5154 
    5255/** 
     
    139142  }; 
    140143 
     144  private static final Logger LOGGER = 
     145    LoggerFactory.getLogger(CBZip2InputStream.class); 
     146 
    141147  private static void reportCRCError() throws IOException { 
    142148    // The clean way would be to throw an exception. 
     
    144150 
    145151    // Just print a message, like the previous versions of this class did 
    146     LogTools.println("BZip2 CRC error"); 
     152    LOGGER.error("BZip2 CRC error"); 
    147153  } 
    148154 
  • branches/cleanup/components/common/src/loci/common/Location.java

    r5824 r5842  
    3232import java.util.ArrayList; 
    3333import java.util.HashMap; 
     34 
     35import org.slf4j.Logger; 
     36import org.slf4j.LoggerFactory; 
    3437 
    3538/** 
     
    4346public class Location { 
    4447 
     48  // -- Constants -- 
     49 
     50  private static final Logger LOGGER = LoggerFactory.getLogger(Location.class); 
     51 
    4552  // -- Static fields -- 
    4653 
     
    5764 
    5865  public Location(String pathname) { 
     66    LOGGER.trace("Location({})", pathname); 
    5967    try { 
    6068      url = new URL(getMappedId(pathname)); 
    6169    } 
    6270    catch (MalformedURLException e) { 
     71      LOGGER.trace("Location is not a URL", e); 
    6372      isURL = false; 
    6473    } 
     
    6776 
    6877  public Location(File file) { 
     78    LOGGER.trace("Location({})", file); 
    6979    isURL = false; 
    7080    this.file = file; 
     
    95105    if (filename == null) idMap.remove(id); 
    96106    else idMap.put(id, filename); 
    97     LogTools.debug("Location.mapId: " + id + " -> " + filename); 
     107    LOGGER.debug("Location.mapId: {} -> {}", id, filename); 
    98108  } 
    99109 
     
    103113    if (ira == null) idMap.remove(id); 
    104114    else idMap.put(id, ira); 
    105     LogTools.debug("Location.mapFile: " + id + " -> " + ira); 
     115    LOGGER.debug("Location.mapFile: {} -> {}", id, ira); 
    106116  } 
    107117 
     
    162172    throws IOException 
    163173  { 
     174    LOGGER.trace("getHandle(id = {}, writable = {})", id, writable); 
    164175    IRandomAccess handle = getMappedFile(id); 
    165176    if (handle == null) { 
     177      LOGGER.trace("no handle was mapped for this ID"); 
    166178      String mapId = getMappedId(id); 
    167179 
     
    182194      } 
    183195    } 
    184     LogTools.debug("Location.getHandle: " + id + " -> " + handle); 
     196    LOGGER.debug("Location.getHandle: {} -> {}", id, handle); 
    185197    return handle; 
    186198  } 
     
    224236      } 
    225237      catch (IOException e) { 
     238        LOGGER.trace("Could not retrieve directory listing", e); 
    226239        return null; 
    227240      } 
     
    323336      } 
    324337      catch (IOException e) { 
     338        LOGGER.trace("Failed to retrieve content from URL", e); 
    325339        return false; 
    326340      } 
     
    450464        return url.openConnection().getLastModified(); 
    451465      } 
    452       catch (IOException e) { return 0; } 
     466      catch (IOException e) { 
     467        LOGGER.trace("Could not determine URL's last modification time", e); 
     468        return 0; 
     469      } 
    453470    } 
    454471    return file.lastModified(); 
     
    464481        return url.openConnection().getContentLength(); 
    465482      } 
    466       catch (IOException e) { return 0; } 
     483      catch (IOException e) { 
     484        LOGGER.trace("Could not determine URL's content length", e); 
     485        return 0; 
     486      } 
    467487    } 
    468488    return file.length(); 
  • branches/cleanup/components/common/src/loci/common/ReflectedUniverse.java

    r5523 r5842  
    3636import java.util.StringTokenizer; 
    3737 
     38import org.slf4j.Logger; 
     39import org.slf4j.LoggerFactory; 
     40 
    3841/** 
    3942 * A general-purpose reflection wrapper class. 
     
    4548public class ReflectedUniverse { 
    4649 
     50  // -- Constants -- 
     51 
     52  private static final Logger LOGGER = 
     53    LoggerFactory.getLogger(ReflectedUniverse.class); 
     54 
    4755  // -- Fields -- 
    4856 
     
    5563  /** Whether to force our way past restrictive access modifiers. */ 
    5664  protected boolean force; 
    57  
    58   /** Debugging flag. */ 
    59   protected boolean debug; 
    6065 
    6166  // -- Constructors -- 
     
    7782    variables = new HashMap<String, Object>(); 
    7883    this.loader = loader == null ? getClass().getClassLoader() : loader; 
    79     debug = false; 
    8084  } 
    8185 
     
    142146      } 
    143147      catch (NoClassDefFoundError err) { 
    144         if (debug) LogTools.trace(err); 
     148        LOGGER.debug("No such class: {}", command, err); 
    145149        throw new ReflectException("No such class: " + command, err); 
    146150      } 
    147151      catch (ClassNotFoundException exc) { 
    148         if (debug) LogTools.trace(exc); 
     152        LOGGER.debug("No such class: {}", command, exc); 
    149153        throw new ReflectException("No such class: " + command, exc); 
    150154      } 
     
    153157        String msg = exc.getMessage(); 
    154158        if (msg != null && msg.indexOf("ClassNotFound") < 0) throw exc; 
    155         if (debug) LogTools.trace(exc); 
     159        LOGGER.debug("No such class: {}", command, exc); 
    156160        throw new ReflectException("No such class: " + command, exc); 
    157161      } 
     
    248252      catch (InvocationTargetException e) { exc = e; } 
    249253      if (exc != null) { 
    250         if (debug) LogTools.trace(exc); 
     254        LOGGER.debug("Cannot instantiate object", exc); 
    251255        throw new ReflectException("Cannot instantiate object", exc); 
    252256      } 
     
    301305      catch (InvocationTargetException e) { exc = e; } 
    302306      if (exc != null) { 
    303         if (debug) LogTools.trace(exc); 
     307        LOGGER.debug("Cannot execute method: {}", methodName, exc); 
    304308        throw new ReflectException("Cannot execute method: " + methodName, exc); 
    305309      } 
     
    412416      } 
    413417      catch (NoSuchFieldException exc) { 
    414         if (debug) LogTools.trace(exc); 
     418        LOGGER.debug("No such field: {}", varName, exc); 
    415419        throw new ReflectException("No such field: " + varName, exc); 
    416420      } 
     
    418422      try { fieldVal = field.get(var); } 
    419423      catch (IllegalAccessException exc) { 
    420         if (debug) LogTools.trace(exc); 
     424        LOGGER.debug("Cannot get field value: {}", varName, exc); 
    421425        throw new ReflectException("Cannot get field value: " + varName, exc); 
    422426      } 
     
    435439  /** Gets whether access modifiers (protected, private, etc.) are ignored. */ 
    436440  public boolean isAccessibilityIgnored() { return force; } 
    437  
    438   /** Enables or disables extended debugging output. */ 
    439   public void setDebug(boolean debug) { this.debug = debug; } 
    440  
    441   /** Gets whether extended debugging output is enabled. */ 
    442   public boolean isDebug() { return debug; } 
    443441 
    444442  // -- Main method -- 
     
    449447  public static void main(String[] args) throws IOException { 
    450448    ReflectedUniverse r = new ReflectedUniverse(); 
    451     LogTools.println("Reflected universe test environment. " + 
     449    System.out.println("Reflected universe test environment. " + 
    452450      "Type commands, or press ^D to quit."); 
    453451    if (args.length > 0) { 
    454452      r.setAccessibilityIgnored(true); 
    455       LogTools.println("Ignoring accessibility modifiers."); 
     453      System.out.println("Ignoring accessibility modifiers."); 
    456454    } 
    457455    BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); 
    458456    while (true) { 
    459       LogTools.print("> "); 
     457      System.out.print("> "); 
    460458      String line = in.readLine(); 
    461459      if (line == null) break; 
    462460      try { r.exec(line); } 
    463       catch (ReflectException exc) { LogTools.trace(exc); } 
    464     } 
    465     LogTools.println(); 
     461      catch (ReflectException exc) { 
     462        LOGGER.debug("Could not execute '{}'", line, exc); 
     463      } 
     464    } 
     465    System.out.println(); 
    466466  } 
    467467 
  • branches/cleanup/components/common/src/loci/common/XMLTools.java

    r5533 r5842  
    5656import javax.xml.validation.Validator; 
    5757 
     58import org.slf4j.Logger; 
     59import org.slf4j.LoggerFactory; 
     60 
    5861import org.w3c.dom.Document; 
    5962import org.xml.sax.Attributes; 
     
    9194    TransformerFactory.newInstance(); 
    9295 
     96  private static final Logger LOGGER = LoggerFactory.getLogger(XMLTools.class); 
     97 
    9398  // -- Constructor -- 
    9499 
     
    302307      } 
    303308      catch (IOException exc) { 
    304         LogTools.traceDebug(exc); 
     309        LOGGER.debug("Could not open file", exc); 
    305310        return null; 
    306311      } 
     
    315320    } 
    316321    catch (TransformerConfigurationException exc) { 
    317       LogTools.traceDebug(exc); 
     322      LOGGER.debug("Could not construct template", exc); 
    318323    } 
    319324    return null; 
     
    377382 
    378383    // get path to schema from root element using SAX 
    379     LogTools.println("Parsing schema path"); 
     384    LOGGER.info("Parsing schema path"); 
    380385    ValidationSAXHandler saxHandler = new ValidationSAXHandler(); 
    381386    try { 
     
    388393    catch (IOException exc) { exception = exc; } 
    389394    if (exception != null) { 
    390       LogTools.println("Error parsing schema path from " + label + ":"); 
    391       LogTools.trace(exception); 
     395      LOGGER.warn("Error parsing schema path from {}", label, exception); 
    392396      return false; 
    393397    } 
    394398    String schemaPath = saxHandler.getSchemaPath(); 
    395399    if (schemaPath == null) { 
    396       LogTools.println("No schema path found. Validation cannot continue."); 
     400      LOGGER.error("No schema path found. Validation cannot continue."); 
    397401      return false; 
    398402    } 
    399     else LogTools.println(schemaPath); 
    400  
    401     LogTools.println("Validating " + label); 
     403    else LOGGER.info(schemaPath); 
     404 
     405    LOGGER.info("Validating {}", label); 
    402406 
    403407    // look up a factory for the W3C XML Schema language 
     
    411415    } 
    412416    catch (MalformedURLException exc) { 
    413       LogTools.println("Error accessing schema at " + schemaPath + ":"); 
    414       LogTools.trace(exc); 
     417      LOGGER.info("Error accessing schema at {}", schemaPath, exc); 
    415418      return false; 
    416419    } 
     
    420423    } 
    421424    catch (SAXException exc) { 
    422       LogTools.println("Error parsing schema at " + schemaPath + ":"); 
    423       LogTools.trace(exc); 
     425      LOGGER.info("Error parsing schema at {}", schemaPath, exc); 
    424426      return false; 
    425427    } 
     
    442444    catch (SAXException exc) { exception = exc; } 
    443445    if (exception != null) { 
    444       LogTools.println("Error validating document:"); 
    445       LogTools.trace(exception); 
     446      LOGGER.info("Error validating document", exception); 
    446447      return false; 
    447448    } 
    448     if (errorHandler.ok()) LogTools.println("No validation errors found."); 
     449    if (errorHandler.ok()) LOGGER.info("No validation errors found."); 
    449450    return errorHandler.ok(); 
    450451  } 
     
    497498    public boolean ok() { return ok; } 
    498499    public void error(SAXParseException e) { 
    499       LogTools.println("error: " + e.getMessage()); 
     500      LOGGER.error(e.getMessage(), e); 
    500501      ok = false; 
    501502    } 
    502503    public void fatalError(SAXParseException e) { 
    503       LogTools.println("fatal error: " + e.getMessage()); 
     504      LOGGER.error(e.getMessage(), e); 
    504505      ok = false; 
    505506    } 
    506507    public void warning(SAXParseException e) { 
    507       LogTools.println("warning: " + e.getMessage()); 
     508      LOGGER.warn(e.getMessage(), e); 
    508509      ok = false; 
    509510    } 
Note: See TracChangeset for help on using the changeset viewer.