diff --git a/src/java/com/samskivert/Log.java b/src/java/com/samskivert/Log.java index df4c3c4f..7fc8597d 100644 --- a/src/java/com/samskivert/Log.java +++ b/src/java/com/samskivert/Log.java @@ -20,8 +20,7 @@ package com.samskivert; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.samskivert.util.Logger; /** * Contains a reference to the log object used by the samskivert package. @@ -30,28 +29,4 @@ public class Log { /** We dispatch our log messages through this logger. */ public static Logger log = Logger.getLogger("com.samskivert"); - - /** Convenience function. */ - public static void debug (String message) - { - log.fine(message); - } - - /** Convenience function. */ - public static void info (String message) - { - log.info(message); - } - - /** Convenience function. */ - public static void warning (String message) - { - log.warning(message); - } - - /** Convenience function. */ - public static void logStackTrace (Throwable t) - { - log.log(Level.WARNING, t.getMessage(), t); - } } diff --git a/src/java/com/samskivert/io/StreamUtil.java b/src/java/com/samskivert/io/StreamUtil.java index a3f6065c..ced01fa6 100644 --- a/src/java/com/samskivert/io/StreamUtil.java +++ b/src/java/com/samskivert/io/StreamUtil.java @@ -26,7 +26,7 @@ import java.io.OutputStream; import java.io.Writer; import java.io.Reader; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * Convenience methods for streams. @@ -42,7 +42,7 @@ public class StreamUtil try { in.close(); } catch (IOException ioe) { - Log.warning("Error closing input stream [stream=" + in + ", cause=" + ioe + "]."); + log.warning("Error closing input stream [stream=" + in + ", cause=" + ioe + "]."); } } } @@ -56,7 +56,7 @@ public class StreamUtil try { out.close(); } catch (IOException ioe) { - Log.warning("Error closing output stream [stream=" + out + ", cause=" + ioe + "]."); + log.warning("Error closing output stream [stream=" + out + ", cause=" + ioe + "]."); } } } @@ -70,7 +70,7 @@ public class StreamUtil try { in.close(); } catch (IOException ioe) { - Log.warning("Error closing reader [reader=" + in + ", cause=" + ioe + "]."); + log.warning("Error closing reader [reader=" + in + ", cause=" + ioe + "]."); } } } @@ -84,7 +84,7 @@ public class StreamUtil try { out.close(); } catch (IOException ioe) { - Log.warning("Error closing writer [writer=" + out + ", cause=" + ioe + "]."); + log.warning("Error closing writer [writer=" + out + ", cause=" + ioe + "]."); } } } diff --git a/src/java/com/samskivert/jdbc/BaseLiaison.java b/src/java/com/samskivert/jdbc/BaseLiaison.java index 2ddfb055..b9190232 100644 --- a/src/java/com/samskivert/jdbc/BaseLiaison.java +++ b/src/java/com/samskivert/jdbc/BaseLiaison.java @@ -25,9 +25,10 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import com.samskivert.Log; import com.samskivert.util.StringUtil; +import static com.samskivert.Log.log; + /** * A superclass to help with the shrinking subset of SQL our supported dialects can agree on, * or when there is disagreement, implement the most standard-compliant version and let the @@ -108,7 +109,7 @@ public abstract class BaseLiaison implements DatabaseLiaison update.append(")"); executeQuery(conn, update.toString()); - Log.info("Database index '" + ixName + "' added to table '" + table + "'"); + log.info("Database index '" + ixName + "' added to table '" + table + "'"); return true; } @@ -127,7 +128,7 @@ public abstract class BaseLiaison implements DatabaseLiaison String update = "ALTER TABLE " + tableSQL(table) + " ADD PRIMARY KEY " + fields.toString(); executeQuery(conn, update.toString()); - Log.info("Primary key " + fields + " added to table '" + table + "'"); + log.info("Primary key " + fields + " added to table '" + table + "'"); } // from DatabaseLiaison @@ -155,7 +156,7 @@ public abstract class BaseLiaison implements DatabaseLiaison executeQuery(conn, "ALTER TABLE " + tableSQL(table) + " ADD COLUMN " + columnSQL(column) + " " + definition); - Log.info("Database column '" + column + "' added to table '" + table + "'."); + log.info("Database column '" + column + "' added to table '" + table + "'."); return true; } @@ -170,7 +171,7 @@ public abstract class BaseLiaison implements DatabaseLiaison executeQuery(conn, "ALTER TABLE " + tableSQL(table) + " CHANGE " + columnSQL(column) + " " + columnSQL(column) + " " + defStr); - Log.info("Database column '" + column + "' of table '" + table + "' modified to have " + + log.info("Database column '" + column + "' of table '" + table + "' modified to have " + "definition '" + defStr + "'."); return true; } @@ -182,7 +183,7 @@ public abstract class BaseLiaison implements DatabaseLiaison { executeQuery(conn, "ALTER TABLE " + tableSQL(table) + " RENAME COLUMN " + columnSQL(from) + " TO " + columnSQL(to)); - Log.info("Renamed column '" + from + "' on table '" + table + "' to '" + to + "'"); + log.info("Renamed column '" + from + "' on table '" + table + "' to '" + to + "'"); return true; } @@ -193,7 +194,7 @@ public abstract class BaseLiaison implements DatabaseLiaison return false; } executeQuery(conn, "ALTER TABLE " + tableSQL(table) + " DROP COLUMN " + columnSQL(column)); - Log.info("Database column '" + column + "' removed from table '" + table + "'."); + log.info("Database column '" + column + "' removed from table '" + table + "'."); return true; } @@ -247,7 +248,7 @@ public abstract class BaseLiaison implements DatabaseLiaison builder.append(")"); executeQuery(conn, builder.toString()); - Log.info("Database table '" + table + "' created."); + log.info("Database table '" + table + "' created."); return true; } diff --git a/src/java/com/samskivert/jdbc/JDBCUtil.java b/src/java/com/samskivert/jdbc/JDBCUtil.java index 24fb8e76..daa0ed64 100644 --- a/src/java/com/samskivert/jdbc/JDBCUtil.java +++ b/src/java/com/samskivert/jdbc/JDBCUtil.java @@ -29,10 +29,11 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import com.samskivert.Log; import com.samskivert.io.PersistenceException; import com.samskivert.util.StringUtil; +import static com.samskivert.Log.log; + /** * A repository for JDBC related utility functions. */ @@ -114,7 +115,7 @@ public class JDBCUtil { int modified = stmt.executeUpdate(); if (modified != expectedCount) { - Log.warning("Statement did not modify expected number of rows [stmt=" + stmt + + log.warning("Statement did not modify expected number of rows [stmt=" + stmt + ", expected=" + expectedCount + ", modified=" + modified + "]"); } } @@ -183,7 +184,7 @@ public class JDBCUtil { int modified = stmt.executeUpdate(query); if (modified != expectedCount) { - Log.warning("Statement did not modify expected number of rows [stmt=" + stmt + + log.warning("Statement did not modify expected number of rows [stmt=" + stmt + ", expected=" + expectedCount + ", modified=" + modified + "]"); } } @@ -230,7 +231,7 @@ public class JDBCUtil try { return new String(text.getBytes("UTF8"), "8859_1"); } catch (UnsupportedEncodingException uee) { - Log.logStackTrace(uee); + log.warning("jigger failed", uee); return text; } } @@ -246,7 +247,7 @@ public class JDBCUtil try { return new String(text.getBytes("8859_1"), "UTF8"); } catch (UnsupportedEncodingException uee) { - Log.logStackTrace(uee); + log.warning("unjigger failed", uee); return text; } } @@ -281,7 +282,7 @@ public class JDBCUtil close(stmt); } - Log.info("Database table '" + table + "' created."); + log.info("Database table '" + table + "' created."); return true; } @@ -480,7 +481,7 @@ public class JDBCUtil } finally { close(stmt); } - Log.info("Database column '" + cname + "' added to table '" + table + "'."); + log.info("Database column '" + cname + "' added to table '" + table + "'."); return true; } @@ -502,7 +503,7 @@ public class JDBCUtil } finally { close(stmt); } - Log.info("Database column '" + cname + "' of table '" + table + + log.info("Database column '" + cname + "' of table '" + table + "' modified to have this def '" + cdef + "'."); } @@ -523,7 +524,7 @@ public class JDBCUtil try { stmt = conn.prepareStatement(update); if (stmt.executeUpdate() == 1) { - Log.info("Database index '" + cname + "' removed from table '" + table + "'."); + log.info("Database index '" + cname + "' removed from table '" + table + "'."); } } finally { close(stmt); @@ -548,7 +549,7 @@ public class JDBCUtil try { stmt = conn.prepareStatement(update); if (stmt.executeUpdate() == 1) { - Log.info("Database index '" + iname + "' removed from table '" + table + "'."); + log.info("Database index '" + iname + "' removed from table '" + table + "'."); } } finally { close(stmt); @@ -567,7 +568,7 @@ public class JDBCUtil try { stmt = conn.prepareStatement(update); if (stmt.executeUpdate() == 1) { - Log.info("Database primary key removed from '" + table + "'."); + log.info("Database primary key removed from '" + table + "'."); } } finally { close(stmt); @@ -600,7 +601,7 @@ public class JDBCUtil } finally { close(stmt); } - Log.info("Database index '" + idx_name + "' added to table '" + table + "'"); + log.info("Database index '" + idx_name + "' added to table '" + table + "'"); return true; } diff --git a/src/java/com/samskivert/jdbc/LiaisonRegistry.java b/src/java/com/samskivert/jdbc/LiaisonRegistry.java index 92488b54..05411dba 100644 --- a/src/java/com/samskivert/jdbc/LiaisonRegistry.java +++ b/src/java/com/samskivert/jdbc/LiaisonRegistry.java @@ -25,7 +25,7 @@ import java.sql.*; import java.util.ArrayList; import java.util.HashMap; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * The liaison registry provides access to the appropriate database liaison implementation for a @@ -52,7 +52,7 @@ public class LiaisonRegistry // if we didn't find a matching liaison, use the default if (liaison == null) { - Log.warning("Unable to match liaison for database [url=" + url + "]. " + + log.warning("Unable to match liaison for database [url=" + url + "]. " + "Using default."); liaison = new DefaultLiaison(); } @@ -79,7 +79,7 @@ public class LiaisonRegistry try { _liaisons.add(lclass.newInstance()); } catch (Exception e) { - Log.warning("Unable to instantiate liaison [class=" + lclass.getName() + + log.warning("Unable to instantiate liaison [class=" + lclass.getName() + ", error=" + e + "]."); } } diff --git a/src/java/com/samskivert/jdbc/MySQLLiaison.java b/src/java/com/samskivert/jdbc/MySQLLiaison.java index cea0d95c..3b5377e5 100644 --- a/src/java/com/samskivert/jdbc/MySQLLiaison.java +++ b/src/java/com/samskivert/jdbc/MySQLLiaison.java @@ -22,7 +22,7 @@ package com.samskivert.jdbc; import java.sql.*; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * A database liaison for the MySQL database. @@ -99,7 +99,7 @@ public class MySQLLiaison extends BaseLiaison update.append(")"); executeQuery(conn, update.toString()); - Log.info("Database index '" + ixName + "' added to table '" + table + "'"); + log.info("Database index '" + ixName + "' added to table '" + table + "'"); return true; } @@ -127,7 +127,7 @@ public class MySQLLiaison extends BaseLiaison } executeQuery(conn, "ALTER TABLE " + table + " CHANGE " + oldColumnName + " " + newColumnName + " " + expandDefinition(newColumnDef)); - Log.info("Renamed column '" + oldColumnName + "' on table '" + table + "' to '" + + log.info("Renamed column '" + oldColumnName + "' on table '" + table + "' to '" + newColumnName + "'"); return true; } diff --git a/src/java/com/samskivert/jdbc/PostgreSQLLiaison.java b/src/java/com/samskivert/jdbc/PostgreSQLLiaison.java index 213f52b1..acacd1a2 100644 --- a/src/java/com/samskivert/jdbc/PostgreSQLLiaison.java +++ b/src/java/com/samskivert/jdbc/PostgreSQLLiaison.java @@ -22,7 +22,7 @@ package com.samskivert.jdbc; import java.sql.*; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * A database liaison for the MySQL database. @@ -87,34 +87,34 @@ public class PostgreSQLLiaison extends BaseLiaison Boolean nullable, Boolean unique, String defaultValue) throws SQLException { - StringBuilder log = new StringBuilder(); + StringBuilder lbuf = new StringBuilder(); if (type != null) { executeQuery( conn, "ALTER TABLE " + tableSQL(table) + " ALTER COLUMN " + columnSQL(column) + " TYPE " + type); - log.append("type=" + type); + lbuf.append("type=" + type); } if (nullable != null) { executeQuery( conn, "ALTER TABLE " + tableSQL(table) + " ALTER COLUMN " + columnSQL(column) + " " + (nullable.booleanValue() ? "SET NOT NULL" : "DROP NOT NULL")); - if (log.length() > 0) log.append(", "); - log.append("nullable=" + nullable); + if (lbuf.length() > 0) lbuf.append(", "); + lbuf.append("nullable=" + nullable); } if (unique != null) { // TODO: I think this requires ALTER TABLE DROP CONSTRAINT and so on - if (log.length() > 0) log.append(", "); - log.append("unique=" + unique + " (not implemented yet)"); + if (lbuf.length() > 0) lbuf.append(", "); + lbuf.append("unique=" + unique + " (not implemented yet)"); } if (defaultValue != null) { executeQuery( conn, "ALTER TABLE " + tableSQL(table) + " ALTER COLUMN " + columnSQL(column) + " " + (defaultValue.length() > 0 ? "SET DEFAULT " + defaultValue : "DROP DEFAULT")); - if (log.length() > 0) log.append(", "); - log.append("defaultValue=" + defaultValue); + if (lbuf.length() > 0) lbuf.append(", "); + lbuf.append("defaultValue=" + defaultValue); } - Log.info("Database column '" + column + "' of table '" + table + "' modified to have " + - "definition [" + log + "]."); + log.info("Database column '" + column + "' of table '" + table + "' modified to have " + + "definition [" + lbuf + "]."); return true; } diff --git a/src/java/com/samskivert/jdbc/SimpleRepository.java b/src/java/com/samskivert/jdbc/SimpleRepository.java index 651df95a..154d194d 100644 --- a/src/java/com/samskivert/jdbc/SimpleRepository.java +++ b/src/java/com/samskivert/jdbc/SimpleRepository.java @@ -22,10 +22,11 @@ package com.samskivert.jdbc; import java.sql.*; -import com.samskivert.Log; import com.samskivert.io.PersistenceException; import com.samskivert.util.StringUtil; +import static com.samskivert.Log.log; + /** * The simple repository should be used for a repository that only needs access to a single JDBC * connection instance to perform its persistence services. @@ -90,8 +91,7 @@ public class SimpleRepository extends Repository } }); } catch (PersistenceException pe) { - Log.warning("Failure migrating schema [dbident=" + _dbident + "]."); - Log.logStackTrace(pe); + log.warning("Failure migrating schema [dbident=" + _dbident + "].", pe); } } @@ -143,7 +143,7 @@ public class SimpleRepository extends Repository // check our pre-condition if (_precond != null && !_precond.validate(_dbident, op)) { - Log.warning("Repository operation failed pre-condition check! [dbident=" + _dbident + + log.warning("Repository operation failed pre-condition check! [dbident=" + _dbident + ", op=" + op + "]."); Thread.dumpStack(); } @@ -193,7 +193,7 @@ public class SimpleRepository extends Repository conn.rollback(); } } catch (SQLException rbe) { - Log.warning("Unable to roll back operation [err=" + sqe + + log.warning("Unable to roll back operation [err=" + sqe + ", rberr=" + rbe + "]."); } } @@ -215,7 +215,7 @@ public class SimpleRepository extends Repository // stack trace in the message of their outer exception; if I want a fucking stack // trace, I'll call printStackTrace() thanksverymuch String msg = StringUtil.split("" + sqe, "\n")[0]; - Log.info("Transient failure executing operation, retrying [error=" + msg + "]."); + log.info("Transient failure executing operation, retrying [error=" + msg + "]."); } catch (PersistenceException pe) { // back out our changes if something got hosed @@ -224,7 +224,7 @@ public class SimpleRepository extends Repository conn.rollback(); } } catch (SQLException rbe) { - Log.warning("Unable to roll back operation [origerr=" + pe + + log.warning("Unable to roll back operation [origerr=" + pe + ", rberr=" + rbe + "]."); } throw pe; @@ -236,7 +236,7 @@ public class SimpleRepository extends Repository conn.rollback(); } } catch (SQLException rbe) { - Log.warning("Unable to roll back operation [origerr=" + rte + + log.warning("Unable to roll back operation [origerr=" + rte + ", rberr=" + rbe + "]."); } throw rte; @@ -249,7 +249,7 @@ public class SimpleRepository extends Repository conn.setAutoCommit(oldAutoCommit); } } catch (SQLException sace) { - Log.warning("Unable to restore auto-commit [err=" + sace + "]."); + log.warning("Unable to restore auto-commit [err=" + sace + "]."); } // release the database connection _provider.releaseConnection(_dbident, readOnly, conn); @@ -354,7 +354,7 @@ public class SimpleRepository extends Repository String result = rs.getString("Msg_text"); if (result == null || (result.indexOf("up to date") == -1 && !result.equals("OK"))) { - Log.info("Table maintenance [" + SimpleRepository.toString(rs) + "]."); + log.info("Table maintenance [" + SimpleRepository.toString(rs) + "]."); } } diff --git a/src/java/com/samskivert/jdbc/StaticConnectionProvider.java b/src/java/com/samskivert/jdbc/StaticConnectionProvider.java index 6764618f..28860f7a 100644 --- a/src/java/com/samskivert/jdbc/StaticConnectionProvider.java +++ b/src/java/com/samskivert/jdbc/StaticConnectionProvider.java @@ -24,12 +24,13 @@ import java.io.IOException; import java.sql.*; import java.util.*; -import com.samskivert.Log; import com.samskivert.io.PersistenceException; import com.samskivert.util.ConfigUtil; import com.samskivert.util.PropertiesUtil; import com.samskivert.util.StringUtil; +import static com.samskivert.Log.log; + /** * The static connection provider generates JDBC connections based on configuration information * provided via a properties file. It does no connection pooling and always returns the same @@ -131,7 +132,7 @@ public class StaticConnectionProvider implements ConnectionProvider String key = username + "@" + url + ":" + readOnly; conmap = _keys.get(key); if (conmap == null) { - Log.debug("Creating " + key + " for " + ident + "."); + log.debug("Creating " + key + " for " + ident + "."); conmap = new Mapping(); conmap.key = key; conmap.connection = openConnection(driver, url, username, password); @@ -151,7 +152,7 @@ public class StaticConnectionProvider implements ConnectionProvider _keys.put(key, conmap); } else { - Log.debug("Reusing " + key + " for " + ident + "."); + log.debug("Reusing " + key + " for " + ident + "."); } // cache the connection @@ -175,7 +176,7 @@ public class StaticConnectionProvider implements ConnectionProvider String mapkey = ident + ":" + readOnly; Mapping conmap = _idents.get(mapkey); if (conmap == null) { - Log.warning("Unknown connection failed!? [key=" + mapkey + "]."); + log.warning("Unknown connection failed!? [key=" + mapkey + "]."); return; } @@ -200,7 +201,7 @@ public class StaticConnectionProvider implements ConnectionProvider try { conmap.connection.close(); } catch (SQLException sqe) { - Log.warning("Error shutting down connection [key=" + key + ", err=" + sqe + "]."); + log.warning("Error shutting down connection [key=" + key + ", err=" + sqe + "]."); } } @@ -240,7 +241,7 @@ public class StaticConnectionProvider implements ConnectionProvider try { conn.close(); } catch (SQLException sqe) { - Log.warning("Error closing failed connection [ident=" + ident + + log.warning("Error closing failed connection [ident=" + ident + ", error=" + sqe + "]."); } } diff --git a/src/java/com/samskivert/jdbc/TransitionRepository.java b/src/java/com/samskivert/jdbc/TransitionRepository.java index 7158d256..c8015cd5 100644 --- a/src/java/com/samskivert/jdbc/TransitionRepository.java +++ b/src/java/com/samskivert/jdbc/TransitionRepository.java @@ -25,7 +25,6 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; -import java.util.logging.Level; import com.samskivert.io.PersistenceException; @@ -75,7 +74,7 @@ public class TransitionRepository extends SimpleRepository try { clearTransition(clazz, name); } catch (PersistenceException pe) { - log.log(Level.WARNING, "Failed to clear failed transition [class=" + clazz + + log.warning("Failed to clear failed transition [class=" + clazz + ", name=" + name + "].", pe); } throw e; @@ -84,7 +83,7 @@ public class TransitionRepository extends SimpleRepository try { clearTransition(clazz, name); } catch (PersistenceException pe) { - log.log(Level.WARNING, "Failed to clear failed transition [class=" + clazz + + log.warning("Failed to clear failed transition [class=" + clazz + ", name=" + name + "].", pe); } throw rte; diff --git a/src/java/com/samskivert/jdbc/WriteOnlyUnit.java b/src/java/com/samskivert/jdbc/WriteOnlyUnit.java index a60556fb..d4ecdd5d 100644 --- a/src/java/com/samskivert/jdbc/WriteOnlyUnit.java +++ b/src/java/com/samskivert/jdbc/WriteOnlyUnit.java @@ -20,8 +20,6 @@ package com.samskivert.jdbc; -import java.util.logging.Level; - import com.samskivert.util.Invoker; import static com.samskivert.Log.log; @@ -70,7 +68,7 @@ public abstract class WriteOnlyUnit extends Invoker.Unit */ public void handleFailure (Exception e) { - log.log(Level.WARNING, getFailureMessage(), e); + log.warning(getFailureMessage(), e); } /** diff --git a/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java b/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java index 6fcf694d..14a29bbc 100644 --- a/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java +++ b/src/java/com/samskivert/jdbc/depot/DepotMarshaller.java @@ -35,7 +35,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.util.logging.Level; import com.samskivert.io.PersistenceException; import com.samskivert.jdbc.depot.annotation.Computed; @@ -109,7 +108,7 @@ public class DepotMarshaller try { _schemaVersion = (Integer)field.get(null); } catch (Exception e) { - log.log(Level.WARNING, "Failed to read schema version " + + log.warning("Failed to read schema version " + "[class=" + _pClass + "].", e); } } diff --git a/src/java/com/samskivert/jdbc/depot/Log.java b/src/java/com/samskivert/jdbc/depot/Log.java index 29315fe8..09fbee3a 100644 --- a/src/java/com/samskivert/jdbc/depot/Log.java +++ b/src/java/com/samskivert/jdbc/depot/Log.java @@ -20,8 +20,7 @@ package com.samskivert.jdbc.depot; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.samskivert.util.Logger; /** * Contains a reference to the log object used by this package. diff --git a/src/java/com/samskivert/jdbc/depot/MySQLBuilder.java b/src/java/com/samskivert/jdbc/depot/MySQLBuilder.java index 89abd5e9..e778095a 100644 --- a/src/java/com/samskivert/jdbc/depot/MySQLBuilder.java +++ b/src/java/com/samskivert/jdbc/depot/MySQLBuilder.java @@ -31,7 +31,6 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Set; -import com.samskivert.Log; import com.samskivert.jdbc.JDBCUtil; import com.samskivert.jdbc.depot.FieldMarshaller.BooleanMarshaller; import com.samskivert.jdbc.depot.FieldMarshaller.ByteArrayMarshaller; @@ -50,6 +49,8 @@ import com.samskivert.jdbc.depot.expression.ColumnExp; import com.samskivert.jdbc.depot.expression.EpochSeconds; import com.samskivert.jdbc.depot.operator.Conditionals.FullTextMatch; +import static com.samskivert.Log.log; + public class MySQLBuilder extends SQLBuilder { @@ -170,7 +171,7 @@ public class MySQLBuilder Statement stmt = conn.createStatement(); try { - Log.info("Adding full-text search index: ftsIx_" + fts.name()); + log.info("Adding full-text search index: ftsIx_" + fts.name()); stmt.executeUpdate(update.toString()); } finally { JDBCUtil.close(stmt); diff --git a/src/java/com/samskivert/jdbc/depot/PersistenceContext.java b/src/java/com/samskivert/jdbc/depot/PersistenceContext.java index 088f71af..d4b266c5 100644 --- a/src/java/com/samskivert/jdbc/depot/PersistenceContext.java +++ b/src/java/com/samskivert/jdbc/depot/PersistenceContext.java @@ -24,7 +24,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.util.logging.Level; import java.io.Serializable; import java.sql.Connection; @@ -162,7 +161,7 @@ public class PersistenceContext _cache.shutdown(); } } catch (Throwable t) { - log.log(Level.WARNING, "Failure shutting down Depot cache.", t); + log.warning("Failure shutting down Depot cache.", t); } _conprov.shutdown(); } @@ -250,15 +249,15 @@ public class PersistenceContext if (key != null && _cache != null) { CacheAdapter.CachedValue cacheHit = cacheLookup(key); if (cacheHit != null) { - log.fine("cache hit [key=" + key + ", hit=" + cacheHit + "]"); + log.debug("cache hit [key=" + key + ", hit=" + cacheHit + "]"); T value = cacheHit.getValue(); value = query.transformCacheHit(key, value); if (value != null) { return value; } - log.fine("transformCacheHit returned null; rejecting cached value."); + log.debug("transformCacheHit returned null; rejecting cached value."); } - log.fine("cache miss [key=" + key + "]"); + log.debug("cache miss [key=" + key + "]"); } // otherwise, perform the query @SuppressWarnings("unchecked") T result = (T) invoke(query, null, true); @@ -314,7 +313,7 @@ public class PersistenceContext Thread.dumpStack(); return; } - log.fine("storing [key=" + key + ", value=" + entry + "]"); + log.debug("storing [key=" + key + ", value=" + entry + "]"); CacheAdapter.CacheBin bin = _cache.getCache(key.getCacheId()); CacheAdapter.CachedValue element = bin.lookup(key.getCacheKey()); @@ -328,7 +327,7 @@ public class PersistenceContext Set> listeners = _listenerSets.get(key.getCacheId()); if (listeners != null && listeners.size() > 0) { for (CacheListener listener : listeners) { - log.fine("cascading [listener=" + listener + "]"); + log.debug("cascading [listener=" + listener + "]"); @SuppressWarnings("unchecked") CacheListener casted = (CacheListener)listener; casted.entryCached(key, entry, oldEntry); @@ -368,7 +367,7 @@ public class PersistenceContext if (_cache == null) { return; } - log.fine("invalidating [cacheId=" + cacheId + ", cacheKey=" + cacheKey + "]"); + log.debug("invalidating [cacheId=" + cacheId + ", cacheKey=" + cacheKey + "]"); CacheAdapter.CacheBin bin = _cache.getCache(cacheId); CacheAdapter.CachedValue element = bin.lookup(cacheKey); @@ -384,7 +383,7 @@ public class PersistenceContext if (listeners != null && listeners.size() > 0) { CacheKey key = new SimpleCacheKey(cacheId, cacheKey); for (CacheListener listener : listeners) { - log.fine("cascading [listener=" + listener + "]"); + log.debug("cascading [listener=" + listener + "]"); @SuppressWarnings("unchecked") CacheListener casted = (CacheListener)listener; casted.entryInvalidated(key, oldEntry); @@ -393,7 +392,7 @@ public class PersistenceContext } // then evict the keyed entry, if needed - log.fine("evicting [cacheKey=" + cacheKey + "]"); + log.debug("evicting [cacheKey=" + cacheKey + "]"); bin.remove(cacheKey); } diff --git a/src/java/com/samskivert/jdbc/depot/PostgreSQLBuilder.java b/src/java/com/samskivert/jdbc/depot/PostgreSQLBuilder.java index 1c204763..210c0b0b 100644 --- a/src/java/com/samskivert/jdbc/depot/PostgreSQLBuilder.java +++ b/src/java/com/samskivert/jdbc/depot/PostgreSQLBuilder.java @@ -51,7 +51,7 @@ import com.samskivert.jdbc.depot.operator.Conditionals.FullTextMatch; import com.samskivert.util.ArrayUtil; import com.samskivert.util.StringUtil; -import com.samskivert.Log; +import static com.samskivert.Log.log; public class PostgreSQLBuilder extends SQLBuilder @@ -178,7 +178,7 @@ public class PostgreSQLBuilder Statement stmt = conn.createStatement(); try { - Log.info( + log.info( "Adding full-text search column, index and trigger: " + column + ", " + index + ", " + trigger); liaison.addColumn(conn, table, column, "TSVECTOR", true); diff --git a/src/java/com/samskivert/jdbc/jora/Cursor.java b/src/java/com/samskivert/jdbc/jora/Cursor.java index d03fc973..e5b2cfe0 100644 --- a/src/java/com/samskivert/jdbc/jora/Cursor.java +++ b/src/java/com/samskivert/jdbc/jora/Cursor.java @@ -23,7 +23,7 @@ package com.samskivert.jdbc.jora; import java.util.*; import java.sql.*; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * Cursor is used for successive access to records fetched by SELECT statement. @@ -96,7 +96,7 @@ public class Cursor spurious++; } if (spurious > 0) { - Log.warning("Cursor.get() quietly tossed " + spurious + + log.warning("Cursor.get() quietly tossed " + spurious + " spurious additional records. " + "[query=" + _query + "]."); } diff --git a/src/java/com/samskivert/net/AttachableURLFactory.java b/src/java/com/samskivert/net/AttachableURLFactory.java index d81ea479..84a1743c 100644 --- a/src/java/com/samskivert/net/AttachableURLFactory.java +++ b/src/java/com/samskivert/net/AttachableURLFactory.java @@ -26,7 +26,7 @@ import java.net.URLStreamHandlerFactory; import java.util.HashMap; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * Allows other entities in an application to register URLStreamHandler @@ -92,7 +92,7 @@ public class AttachableURLFactory implements URLStreamHandlerFactory try { return handler.newInstance(); } catch (Exception e) { - Log.warning("Unable to instantiate URLStreamHandler" + + log.warning("Unable to instantiate URLStreamHandler" + " [protocol=" + protocol + ", cause=" + e + "]."); } } diff --git a/src/java/com/samskivert/net/MailUtil.java b/src/java/com/samskivert/net/MailUtil.java index c0df6660..c437f453 100644 --- a/src/java/com/samskivert/net/MailUtil.java +++ b/src/java/com/samskivert/net/MailUtil.java @@ -32,9 +32,10 @@ import javax.mail.internet.MimeMessage; import java.util.regex.PatternSyntaxException; import java.util.regex.Pattern; -import com.samskivert.Log; import com.samskivert.util.StringUtil; +import static com.samskivert.Log.log; + /** * The mail util class encapsulates some utility functions related to * sending emails. @@ -179,8 +180,7 @@ public class MailUtil try { _emailre = Pattern.compile(EMAIL_REGEX); } catch (PatternSyntaxException pse) { - Log.warning("Unable to initialize email regexp?!"); - Log.logStackTrace(pse); + log.warning("Unable to initialize email regexp?!", pse); } } } diff --git a/src/java/com/samskivert/servlet/JDBCTableSiteIdentifier.java b/src/java/com/samskivert/servlet/JDBCTableSiteIdentifier.java index 118fc99b..bfe70406 100644 --- a/src/java/com/samskivert/servlet/JDBCTableSiteIdentifier.java +++ b/src/java/com/samskivert/servlet/JDBCTableSiteIdentifier.java @@ -43,7 +43,7 @@ import com.samskivert.jdbc.SimpleRepository; import com.samskivert.util.ArrayUtil; import com.samskivert.util.HashIntMap; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * Accomplishes the process of site identification based on a mapping from domains (e.g. @@ -187,8 +187,7 @@ public class JDBCTableSiteIdentifier implements SiteIdentifier try { _repo.refreshSiteData(); } catch (PersistenceException pe) { - Log.warning("Error refreshing site data."); - Log.logStackTrace(pe); + log.warning("Error refreshing site data.", pe); } } } diff --git a/src/java/com/samskivert/servlet/MessageManager.java b/src/java/com/samskivert/servlet/MessageManager.java index 3e64c8a1..20534b49 100644 --- a/src/java/com/samskivert/servlet/MessageManager.java +++ b/src/java/com/samskivert/servlet/MessageManager.java @@ -26,10 +26,11 @@ import java.util.*; import javax.servlet.http.HttpServletRequest; -import com.samskivert.Log; import com.samskivert.text.MessageUtil; import com.samskivert.util.StringUtil; +import static com.samskivert.Log.log; + /** * The message manager handles the translation messages for a web application. The webapp should * construct the message manager with the name of its message properties file and it can then make @@ -183,7 +184,7 @@ public class MessageManager if (reportMissing) { // if there's no translation for this path, complain about it - Log.warning("Missing translation message [path=" + path + + log.warning("Missing translation message [path=" + path + ", url=" + getURL(req) + "]."); return path; } @@ -217,7 +218,7 @@ public class MessageManager try { siteLoader = _siteLoader.getSiteClassLoader(siteId); } catch (IOException ioe) { - Log.warning("Unable to fetch site-specific classloader " + + log.warning("Unable to fetch site-specific classloader " + "[siteId=" + siteId + ", error=" + ioe + "]."); } } @@ -292,7 +293,7 @@ public class MessageManager if (!silent) { // if we were unable even to find a default bundle, we may want to log a // warning - Log.warning("Unable to resolve any message bundle [req=" + getURL(req) + + log.warning("Unable to resolve any message bundle [req=" + getURL(req) + ", locale=" + locale + ", bundlePath=" + bundlePath + ", classLoader=" + loader + ", siteBundlePath=" + _siteBundlePath + ", siteLoader=" + _siteLoader + "]."); diff --git a/src/java/com/samskivert/servlet/SiteResourceLoader.java b/src/java/com/samskivert/servlet/SiteResourceLoader.java index ae84a3f7..7fde4836 100644 --- a/src/java/com/samskivert/servlet/SiteResourceLoader.java +++ b/src/java/com/samskivert/servlet/SiteResourceLoader.java @@ -30,9 +30,10 @@ import java.util.jar.JarFile; import javax.servlet.http.HttpServletRequest; -import com.samskivert.Log; import com.samskivert.util.HashIntMap; +import static com.samskivert.Log.log; + /** * Web applications may wish to load resources in such a way that the site * on which they are running is allowed to override a resource with a @@ -317,7 +318,7 @@ public class SiteResourceLoader jarFile.close(); } - Log.info("Opened site bundle [path=" + file.getPath() + "]."); + log.info("Opened site bundle [path=" + file.getPath() + "]."); // and open a new one jarFile = new JarFile(file); @@ -341,7 +342,7 @@ public class SiteResourceLoader try { return _bundle.getResourceAsStream(path); } catch (IOException ioe) { - Log.warning("Error loading resource from jarfile " + + log.warning("Error loading resource from jarfile " + "[bundle=" + _bundle + ", path=" + path + ", error=" + ioe + "]."); return null; diff --git a/src/java/com/samskivert/servlet/user/UserManager.java b/src/java/com/samskivert/servlet/user/UserManager.java index 01d60b1c..b98451d3 100644 --- a/src/java/com/samskivert/servlet/user/UserManager.java +++ b/src/java/com/samskivert/servlet/user/UserManager.java @@ -25,7 +25,6 @@ import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.samskivert.Log; import com.samskivert.io.PersistenceException; import com.samskivert.jdbc.ConnectionProvider; import com.samskivert.servlet.RedirectException; @@ -36,6 +35,8 @@ import com.samskivert.util.RunQueue; import com.samskivert.util.StringUtil; import com.samskivert.util.Tuple; +import static com.samskivert.Log.log; + /** * The user manager provides easy access to user objects for servlets. It takes care of cookie * management involved in login, logout and loading a user record during an authenticated session. @@ -123,7 +124,7 @@ public class UserManager // fetch the login URL from the properties _loginURL = config.getProperty("login_url"); if (_loginURL == null) { - Log.warning("No login_url supplied in user manager config. Authentication won't work."); + log.warning("No login_url supplied in user manager config. Authentication won't work."); _loginURL = "/missing_login_url"; } @@ -134,7 +135,7 @@ public class UserManager } if (USERMGR_DEBUG) { - Log.info("UserManager initialized [acook=" + _userAuthCookie + + log.info("UserManager initialized [acook=" + _userAuthCookie + ", login=" + _loginURL + "]."); } @@ -144,8 +145,7 @@ public class UserManager try { _repository.pruneSessions(); } catch (PersistenceException pe) { - Log.warning("Error pruning session table."); - Log.logStackTrace(pe); + log.warning("Error pruning session table.", pe); } } }; @@ -178,7 +178,7 @@ public class UserManager { String authcook = CookieUtil.getCookieValue(req, _userAuthCookie); if (USERMGR_DEBUG) { - Log.info("Loading user by cookie [" + _userAuthCookie + "=" + authcook + "]."); + log.info("Loading user by cookie [" + _userAuthCookie + "=" + authcook + "]."); } return loadUser(authcook); } @@ -191,7 +191,7 @@ public class UserManager { User user = (authcode == null) ? null : _repository.loadUserBySession(authcode); if (USERMGR_DEBUG) { - Log.info("Loaded user by authcode [code=" + authcode + ", user=" + user + "]."); + log.info("Loaded user by authcode [code=" + authcode + ", user=" + user + "]."); } return user; } @@ -214,7 +214,7 @@ public class UserManager String eurl = RequestUtils.getLocationEncoded(req); String target = StringUtil.replace(_loginURL, "%R", eurl); if (USERMGR_DEBUG) { - Log.info("No user found in require, redirecting [to=" + target + "]."); + log.info("No user found in require, redirecting [to=" + target + "]."); } throw new RedirectException(target); } @@ -252,7 +252,7 @@ public class UserManager // potentially convert the user's legacy password if (password != null && password.getCleartext() != null && user.updateLegacyPassword(password.getCleartext())) { - Log.info("Updated legacy password " + user.username + "."); + log.info("Updated legacy password " + user.username + "."); _repository.updateUser(user); } @@ -291,7 +291,7 @@ public class UserManager // potentially convert the user's legacy password if (password != null && password.getCleartext() != null && user.updateLegacyPassword(password.getCleartext())) { - Log.info("Updated legacy password " + user.username + "."); + log.info("Updated legacy password " + user.username + "."); _repository.updateUser(user); } @@ -301,7 +301,7 @@ public class UserManager // register a session for this user String authcode = _repository.registerSession(user, expires); if (USERMGR_DEBUG) { - Log.info("Session started [user=" + username + ", code=" + authcode + "]."); + log.info("Session started [user=" + username + ", code=" + authcode + "]."); } return new Tuple(user, authcode); } @@ -326,7 +326,7 @@ public class UserManager acookie.setPath("/"); acookie.setMaxAge((expires > 0) ? (expires*24*60*60) : -1); if (USERMGR_DEBUG) { - Log.info("Setting cookie " + acookie + "."); + log.info("Setting cookie " + acookie + "."); } rsp.addCookie(acookie); } @@ -348,7 +348,7 @@ public class UserManager c.setMaxAge(0); CookieUtil.widenDomain(req, c); if (USERMGR_DEBUG) { - Log.info("Clearing cookie " + c + "."); + log.info("Clearing cookie " + c + "."); } rsp.addCookie(c); diff --git a/src/java/com/samskivert/servlet/util/ExceptionMap.java b/src/java/com/samskivert/servlet/util/ExceptionMap.java index 514228ae..c790dd45 100644 --- a/src/java/com/samskivert/servlet/util/ExceptionMap.java +++ b/src/java/com/samskivert/servlet/util/ExceptionMap.java @@ -23,10 +23,11 @@ package com.samskivert.servlet.util; import java.io.*; import java.util.*; -import com.samskivert.Log; import com.samskivert.util.ConfigUtil; import com.samskivert.util.StringUtil; +import static com.samskivert.Log.log; + /** * The exception map is used to map exceptions to error messages based on * a static, server-wide configuration. @@ -88,7 +89,7 @@ public class ExceptionMap ClassLoader cld = ExceptionMap.class.getClassLoader(); InputStream config = ConfigUtil.getStream(PROPS_NAME, cld); if (config == null) { - Log.warning("Unable to load " + PROPS_NAME + " from CLASSPATH."); + log.warning("Unable to load " + PROPS_NAME + " from CLASSPATH."); } else { // otherwise process ye old config file. @@ -117,7 +118,7 @@ public class ExceptionMap _keys.add(cl); } catch (Throwable t) { - Log.warning("Unable to resolve exception class. " + + log.warning("Unable to resolve exception class. " + "[class=" + exclass + ", error=" + t + "]."); _values.remove(i); @@ -126,7 +127,7 @@ public class ExceptionMap } } catch (IOException ioe) { - Log.warning("Error reading exception mapping file: " + ioe); + log.warning("Error reading exception mapping file: " + ioe); } } } diff --git a/src/java/com/samskivert/swing/AbsoluteLayout.java b/src/java/com/samskivert/swing/AbsoluteLayout.java index 167de167..7e677e2b 100644 --- a/src/java/com/samskivert/swing/AbsoluteLayout.java +++ b/src/java/com/samskivert/swing/AbsoluteLayout.java @@ -30,7 +30,7 @@ import java.awt.Rectangle; import java.util.HashMap; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * Used to lay out components at absolute coordinates. This layout manager @@ -85,7 +85,7 @@ public class AbsoluteLayout Object constr = _constraints.get(comp); if (constr == null) { - Log.warning("No constraints for child!? [cont=" + parent + + log.warning("No constraints for child!? [cont=" + parent + ", comp=" + comp + "]."); continue; } @@ -137,7 +137,7 @@ public class AbsoluteLayout Object constr = _constraints.get(comp); if (constr == null) { - Log.warning("No constraints for child!? [cont=" + parent + + log.warning("No constraints for child!? [cont=" + parent + ", comp=" + comp + "]."); continue; } diff --git a/src/java/com/samskivert/swing/Controller.java b/src/java/com/samskivert/swing/Controller.java index d360e40b..ffc3fa2f 100644 --- a/src/java/com/samskivert/swing/Controller.java +++ b/src/java/com/samskivert/swing/Controller.java @@ -34,9 +34,10 @@ import javax.swing.JComponent; import java.awt.event.HierarchyEvent; import java.awt.event.HierarchyListener; -import com.samskivert.Log; import com.samskivert.swing.event.CommandEvent; +import static com.samskivert.Log.log; + /** * The controller class provides a basis for the separation of user interface * code into display code and control code. The display code lives in a panel @@ -296,7 +297,7 @@ public abstract class Controller } } catch (Exception e) { - Log.warning("Error searching for action handler method " + + log.warning("Error searching for action handler method " + "[controller=" + this + ", action=" + action + "]."); return false; } @@ -310,9 +311,8 @@ public abstract class Controller } } catch (Exception e) { - Log.warning("Error invoking action handler [controller=" + this + - ", action=" + action + "]."); - Log.logStackTrace(e); + log.warning("Error invoking action handler [controller=" + this + + ", action=" + action + "].", e); // even though we choked, we still "handled" the action return true; } @@ -369,7 +369,7 @@ public abstract class Controller return new Object[] { source, argument }; } - Log.warning("Unable to map argumentless event to handler method " + + log.warning("Unable to map argumentless event to handler method " + "that requires an argument [controller=" + this + ", method=" + method + ", source=" + source + "]."); } @@ -394,7 +394,7 @@ public abstract class Controller // do some sanity checking on the source Object src = _action.getSource(); if (src == null || !(src instanceof Component)) { - Log.warning("Requested to dispatch action on " + + log.warning("Requested to dispatch action on " + "non-component source [source=" + src + ", action=" + _action + "]."); return; @@ -410,7 +410,7 @@ public abstract class Controller Controller ctrl = ((ControllerProvider)source).getController(); if (ctrl == null) { - Log.warning("Provider returned null controller " + + log.warning("Provider returned null controller " + "[provider=" + source + "]."); continue; } @@ -423,15 +423,14 @@ public abstract class Controller } } catch (Exception e) { - Log.warning("Controller choked on action " + + log.warning("Controller choked on action " + "[ctrl=" + ctrl + - ", action=" + _action + "]."); - Log.logStackTrace(e); + ", action=" + _action + "].", e); } } // if we got here, we didn't find a controller - Log.warning("Unable to find a controller to process action " + + log.warning("Unable to find a controller to process action " + "[action=" + _action + "]."); } diff --git a/src/java/com/samskivert/swing/EnablingAdapter.java b/src/java/com/samskivert/swing/EnablingAdapter.java index 7ab85c46..aaeea3ba 100644 --- a/src/java/com/samskivert/swing/EnablingAdapter.java +++ b/src/java/com/samskivert/swing/EnablingAdapter.java @@ -25,7 +25,7 @@ import java.beans.PropertyChangeListener; import javax.swing.JComponent; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * Used to enable or disable a source component based on some @@ -83,7 +83,7 @@ public class EnablingAdapter if (value instanceof Boolean) { stateChanged(((Boolean)value).booleanValue()); } else { - Log.warning("PropertyChangeEnabler connected to " + + log.warning("PropertyChangeEnabler connected to " + "non-Boolean property [got=" + value + "]."); } } diff --git a/src/java/com/samskivert/swing/Label.java b/src/java/com/samskivert/swing/Label.java index d8154bd7..7190b67d 100644 --- a/src/java/com/samskivert/swing/Label.java +++ b/src/java/com/samskivert/swing/Label.java @@ -44,11 +44,12 @@ import java.util.regex.Pattern; import javax.swing.SwingConstants; -import com.samskivert.Log; import com.samskivert.util.RunAnywhere; import com.samskivert.util.StringUtil; import com.samskivert.util.Tuple; +import static com.samskivert.Log.log; + /** * The label is a multipurpose text display mechanism that can display * small amounts of text wrapped to fit into a variety of constrained @@ -538,9 +539,7 @@ public class Label implements SwingConstants, LabelStyleConstants } } catch (Throwable t) { - Log.warning("Label layout failed [text=" + _text + - ", t=" + t + "]."); - Log.logStackTrace(t); + log.warning("Label layout failed [text=" + _text + "].", t); } return layouts; @@ -554,7 +553,7 @@ public class Label implements SwingConstants, LabelStyleConstants { // nothing to do if we haven't been laid out if (_layouts == null) { - Log.warning(hashCode() + " Unlaid-out label asked to render " + + log.warning(hashCode() + " Unlaid-out label asked to render " + "[text=" + _text + // ", last=" + _invalidator + "]."); @@ -683,7 +682,7 @@ public class Label implements SwingConstants, LabelStyleConstants try { lastColor = new Color(Integer.parseInt(group, 16)); } catch (NumberFormatException nfe) { - Log.warning("This shouldn't be possible, the regex " + + log.warning("This shouldn't be possible, the regex " + "is precise [badcolor=" + group + "]."); } } diff --git a/src/java/com/samskivert/swing/ObjectEditorTable.java b/src/java/com/samskivert/swing/ObjectEditorTable.java index 2b6d8acb..e41b6644 100644 --- a/src/java/com/samskivert/swing/ObjectEditorTable.java +++ b/src/java/com/samskivert/swing/ObjectEditorTable.java @@ -38,7 +38,7 @@ import com.samskivert.util.ClassUtil; import com.samskivert.util.CollectionUtil; import com.samskivert.util.ListUtil; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * Allows simple displaying and editing of Objects in a table format. @@ -87,7 +87,7 @@ public class ObjectEditorTable extends JTable try { return field.get(obj); } catch (IllegalAccessException iae) { - Log.logStackTrace(iae); + log.warning("Failed to get value", "field", field, iae); return null; } } @@ -101,7 +101,7 @@ public class ObjectEditorTable extends JTable try { field.set(obj, value); } catch (IllegalAccessException iae) { - Log.logStackTrace(iae); + log.warning("Failed to set value", "field", field, iae); } } } diff --git a/src/java/com/samskivert/swing/RuntimeAdjust.java b/src/java/com/samskivert/swing/RuntimeAdjust.java index 0073373d..60b1621b 100644 --- a/src/java/com/samskivert/swing/RuntimeAdjust.java +++ b/src/java/com/samskivert/swing/RuntimeAdjust.java @@ -46,13 +46,14 @@ import javax.swing.JTabbedPane; import javax.swing.JTextField; import javax.swing.Scrollable; -import com.samskivert.Log; import com.samskivert.util.ComparableArrayList; import com.samskivert.util.PrefsConfig; import com.samskivert.util.DebugChords; import com.samskivert.util.ListUtil; import com.samskivert.util.StringUtil; +import static com.samskivert.Log.log; + /** * Provides a service where named variables can be registered as adjustable by the developer at * runtime. Generally a special key is configured (via {@link DebugChords}) to pop up the @@ -278,7 +279,7 @@ public class RuntimeAdjust public void setValue (String value) { if (!ListUtil.contains(_values, value)) { - Log.warning("Refusing invalid adjustment [name=" + _name + + log.warning("Refusing invalid adjustment [name=" + _name + ", values=" + StringUtil.toString(_values) + ", value=" + value + "]."); } else { @@ -486,7 +487,7 @@ public class RuntimeAdjust // validate the structure of the name int fdidx = _name.indexOf("."), ldidx = _name.lastIndexOf("."); if (fdidx == -1 || ldidx == -1) { - Log.warning("Invalid adjustment name '" + _name + + log.warning("Invalid adjustment name '" + _name + "', must be of the form " + "'library.package.adjustment'."); return; @@ -495,7 +496,7 @@ public class RuntimeAdjust // make sure there isn't another with the same name int idx = _adjusts.binarySearch(this); if (idx >= 0) { - Log.warning("Error: duplicate adjust registration " + + log.warning("Error: duplicate adjust registration " + "[new=" + this + ", old=" + _adjusts.get(idx) + "]."); return; diff --git a/src/java/com/samskivert/swing/dnd/DnDManager.java b/src/java/com/samskivert/swing/dnd/DnDManager.java index 51ad4c0d..0522671f 100644 --- a/src/java/com/samskivert/swing/dnd/DnDManager.java +++ b/src/java/com/samskivert/swing/dnd/DnDManager.java @@ -43,10 +43,10 @@ import javax.swing.Timer; import javax.swing.event.AncestorEvent; import javax.swing.event.MouseInputAdapter; -import com.samskivert.Log; - import com.samskivert.swing.event.AncestorAdapter; +import static com.samskivert.Log.log; + /** * A custom Drag and Drop manager for use within a single JVM. Does what we * need it to do and no more. @@ -228,7 +228,7 @@ public class DnDManager protected void assertComponentCursorCleared () { if (_lastComp != null) { - Log.warning("In DnDManager, last component cursor not cleared."); + log.warning("In DnDManager, last component cursor not cleared."); clearComponentCursor(); } } @@ -236,7 +236,7 @@ public class DnDManager protected void assertTopCursorCleared () { if (_topComp != null) { - Log.warning("In DnDManager, top component cursor not cleared."); + log.warning("In DnDManager, top component cursor not cleared."); _topComp.setCursor(_topCursor); _topComp = null; } diff --git a/src/java/com/samskivert/swing/util/MenuUtil.java b/src/java/com/samskivert/swing/util/MenuUtil.java index 3cff77c0..33997ca0 100644 --- a/src/java/com/samskivert/swing/util/MenuUtil.java +++ b/src/java/com/samskivert/swing/util/MenuUtil.java @@ -30,7 +30,7 @@ import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import javax.swing.KeyStroke; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * The menu util class provides miscellaneous useful utility routines for @@ -226,7 +226,7 @@ public class MenuUtil _target = target; } catch (Exception e) { - Log.warning("Unable to obtain menu callback method " + + log.warning("Unable to obtain menu callback method " + "[target=" + target + ", method=" + _method + ", error=" + e + "]. Item will not function."); } @@ -238,10 +238,9 @@ public class MenuUtil try { _method.invoke(_target, new Object[] { event }); } catch (Exception e) { - Log.warning("Failure invoking menu callback " + + log.warning("Failure invoking menu callback " + "[target=" + _target + - ", method=" + _method + "]."); - Log.logStackTrace(e); + ", method=" + _method + "].", e); } } } diff --git a/src/java/com/samskivert/swing/util/TaskMaster.java b/src/java/com/samskivert/swing/util/TaskMaster.java index 491cc3d0..9626db66 100644 --- a/src/java/com/samskivert/swing/util/TaskMaster.java +++ b/src/java/com/samskivert/swing/util/TaskMaster.java @@ -24,7 +24,7 @@ import java.lang.reflect.Method; import java.util.Hashtable; import javax.swing.SwingUtilities; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * The task master provides the ability for swing applications to invoke @@ -126,9 +126,7 @@ public class TaskMaster try { _observer.taskCompleted(_name, _result); } catch (Throwable t) { - Log.warning("Observer choked in " + - "taskCompleted(): " + t); - Log.logStackTrace(t); + log.warning("Observer choked in taskCompleted()", t); } break; @@ -136,8 +134,7 @@ public class TaskMaster try { _observer.taskFailed(_name, (Throwable)_result); } catch (Throwable ot) { - Log.warning("Observer choked in taskFailed(): " + ot); - Log.logStackTrace(ot); + log.warning("Observer choked in taskFailed()", ot); } break; } @@ -145,7 +142,7 @@ public class TaskMaster public void abort () { - Log.warning("abort() not currently supported."); + log.warning("abort() not currently supported."); } protected String _name; diff --git a/src/java/com/samskivert/test/TestUtil.java b/src/java/com/samskivert/test/TestUtil.java index 06a4fdb2..51ab6983 100644 --- a/src/java/com/samskivert/test/TestUtil.java +++ b/src/java/com/samskivert/test/TestUtil.java @@ -24,7 +24,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * Utilities used by unit tests for the samskivert library which are @@ -49,7 +49,7 @@ public class TestUtil { String testdir = System.getProperty("test_dir"); if (testdir == null) { - Log.warning("The 'test_dir' system property was not set " + + log.warning("The 'test_dir' system property was not set " + "to the top-level test directory."); // fake it and hope for the best testdir = "."; diff --git a/src/java/com/samskivert/util/AuditLogger.java b/src/java/com/samskivert/util/AuditLogger.java index c3def8d0..ce02b05d 100644 --- a/src/java/com/samskivert/util/AuditLogger.java +++ b/src/java/com/samskivert/util/AuditLogger.java @@ -33,7 +33,7 @@ import java.text.FieldPosition; import java.util.Calendar; import java.util.Date; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * Used by various services to generate audit logs which can be useful for auditing, debugging and @@ -88,10 +88,10 @@ public class AuditLogger _throttled++; } else { if (_throttled > 0) { - Log.warning("Suppressed " + _throttled + " intervening error messages."); + log.warning("Suppressed " + _throttled + " intervening error messages."); _throttled = 0; } - Log.warning("Failed to write audit log message [file=" + _logPath + + log.warning("Failed to write audit log message [file=" + _logPath + ", msg=" + message + "]."); } } @@ -129,7 +129,7 @@ public class AuditLogger if (freakout) { throw new RuntimeException(errmsg, ioe); } else { - Log.warning(errmsg + " [ioe=" + ioe + "]."); + log.warning(errmsg + " [ioe=" + ioe + "]."); } } } @@ -151,7 +151,7 @@ public class AuditLogger // rename the old file String npath = _logPath.getPath() + "." + _dayStamp; if (!_logPath.renameTo(new File(npath))) { - Log.warning("Failed to rename audit log file [path=" + _logPath + + log.warning("Failed to rename audit log file [path=" + _logPath + ", npath=" + npath + "]."); } diff --git a/src/java/com/samskivert/util/BaseArrayList.java b/src/java/com/samskivert/util/BaseArrayList.java index b32acf41..e2094cd7 100644 --- a/src/java/com/samskivert/util/BaseArrayList.java +++ b/src/java/com/samskivert/util/BaseArrayList.java @@ -31,6 +31,8 @@ import java.util.RandomAccess; import java.lang.reflect.Array; +import static com.samskivert.Log.log; + /** * Provides a base for extending the standard Java {@link ArrayList} * functionality (which we'd just extend directly if those pig fuckers hadn't @@ -173,7 +175,7 @@ public abstract class BaseArrayList extends AbstractList return dup; } catch (CloneNotSupportedException cnse) { - com.samskivert.Log.logStackTrace(cnse); // won't happen. + log.warning("clone failed", cnse); // won't happen. return null; } } diff --git a/src/java/com/samskivert/util/BasicRunQueue.java b/src/java/com/samskivert/util/BasicRunQueue.java index 9a7958c5..39116db2 100644 --- a/src/java/com/samskivert/util/BasicRunQueue.java +++ b/src/java/com/samskivert/util/BasicRunQueue.java @@ -20,7 +20,7 @@ package com.samskivert.util; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * A very basic implementation of RunQueue for general purpose use. @@ -57,8 +57,7 @@ public class BasicRunQueue extends LoopingThread r.run(); } catch (Throwable t) { - Log.warning("Runnable posted to RunQueue barfed."); - Log.logStackTrace(t); + log.warning("Runnable posted to RunQueue barfed.", t); } } diff --git a/src/java/com/samskivert/util/ComplainingListener.java b/src/java/com/samskivert/util/ComplainingListener.java index adc708a9..ee86498a 100644 --- a/src/java/com/samskivert/util/ComplainingListener.java +++ b/src/java/com/samskivert/util/ComplainingListener.java @@ -21,7 +21,6 @@ package com.samskivert.util; import java.util.logging.Level; -import java.util.logging.Logger; /** * A ResultListener that does nothing on success and logs a warning message on failure, that's all. @@ -29,15 +28,15 @@ import java.util.logging.Logger; public class ComplainingListener implements ResultListener { - public ComplainingListener (Log log, String errorText) + public ComplainingListener (Logger logger, String errorText) { - _log = log; + _slogger = logger; _errorText = errorText; } - public ComplainingListener (Logger logger, String errorText) + public ComplainingListener (java.util.logging.Logger logger, String errorText) { - _logger = logger; + _jlogger = logger; _errorText = errorText; } @@ -47,20 +46,20 @@ public class ComplainingListener // documentation inherited from interface ResultListener public void requestFailed (Exception cause) { - if (_log != null) { - _log.warning(_errorText + " [cause=" + cause + "]."); - } else if (_logger != null) { - _logger.log(Level.WARNING, _errorText, cause); + if (_slogger != null) { + _slogger.warning(_errorText, cause); + } else if (_jlogger != null) { + _jlogger.log(Level.WARNING, _errorText, cause); } else { System.err.println(_errorText + " [cause=" + cause + "]."); } } /** The log to which we'll log our error, may be null. */ - protected Log _log; + protected Logger _slogger; /** The logger to which we'll log our error, may be null. */ - protected Logger _logger; + protected java.util.logging.Logger _jlogger; /** The text to output if the error happens. */ protected String _errorText; diff --git a/src/java/com/samskivert/util/Config.java b/src/java/com/samskivert/util/Config.java index 1f2a3347..8c31cffc 100644 --- a/src/java/com/samskivert/util/Config.java +++ b/src/java/com/samskivert/util/Config.java @@ -28,7 +28,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Properties; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * The config class provides a unified interaface to application configuration information. It @@ -100,10 +100,10 @@ public class Config ConfigUtil.loadInheritedProperties(ppath, _props); } catch (FileNotFoundException fnfe) { - Log.debug("No properties file found to back config [path=" + path + "]."); + log.debug("No properties file found to back config [path=" + path + "]."); } catch (IOException ioe) { - Log.warning("Unable to load configuration [path=" + path + ", ioe=" + ioe + "]."); + log.warning("Unable to load configuration [path=" + path + ", ioe=" + ioe + "]."); } } @@ -134,7 +134,7 @@ public class Config try { return Integer.decode(val).intValue(); // handles base 10, hex values, etc. } catch (NumberFormatException nfe) { - Log.warning("Malformed integer property [name=" + name + ", value=" + val + "]."); + log.warning("Malformed integer property [name=" + name + ", value=" + val + "]."); } } return defval; @@ -159,7 +159,7 @@ public class Config try { defval = Long.parseLong(val); } catch (NumberFormatException nfe) { - Log.warning("Malformed long integer property [name=" + name + + log.warning("Malformed long integer property [name=" + name + ", value=" + val + "]."); } } @@ -185,7 +185,7 @@ public class Config try { defval = Float.parseFloat(val); } catch (NumberFormatException nfe) { - Log.warning("Malformed float property [name=" + name + + log.warning("Malformed float property [name=" + name + ", value=" + val + "]."); } } @@ -248,7 +248,7 @@ public class Config if (val != null) { result = StringUtil.parseIntArray(val); if (result == null) { - Log.warning("Malformed int array property [name=" + name + + log.warning("Malformed int array property [name=" + name + ", value=" + val + "]."); return defval; } @@ -279,7 +279,7 @@ public class Config if (val != null) { result = StringUtil.parseLongArray(val); if (result == null) { - Log.warning("Malformed int array property [name=" + name + + log.warning("Malformed int array property [name=" + name + ", value=" + val + "]."); return defval; } @@ -310,7 +310,7 @@ public class Config if (val != null) { result = StringUtil.parseFloatArray(val); if (result == null) { - Log.warning("Malformed int array property [name=" + name + + log.warning("Malformed int array property [name=" + name + ", value=" + val + "]."); return defval; } @@ -341,7 +341,7 @@ public class Config if (val != null) { result = StringUtil.parseStringArray(val); if (result == null) { - Log.warning("Malformed string array property [name=" + name + + log.warning("Malformed string array property [name=" + name + ", value=" + val + "]."); return defval; } diff --git a/src/java/com/samskivert/util/ConfigUtil.java b/src/java/com/samskivert/util/ConfigUtil.java index e343007e..7be95f31 100644 --- a/src/java/com/samskivert/util/ConfigUtil.java +++ b/src/java/com/samskivert/util/ConfigUtil.java @@ -25,7 +25,7 @@ import java.net.URL; import java.security.AccessControlException; import java.util.*; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * The config util class provides routines for loading configuration @@ -51,7 +51,7 @@ public class ConfigUtil try { value = Integer.parseInt(valstr); } catch (NumberFormatException nfe) { - Log.warning("'" + key + "' must be a numeric value " + + log.warning("'" + key + "' must be a numeric value " + "[value=" + valstr + ", error=" + nfe + "]."); } } @@ -314,7 +314,7 @@ public class ConfigUtil // best to work around it InputStream in = getStream(path, loader); if (in != null) { - Log.warning("Buggy classloader: getResources() returned " + + log.warning("Buggy classloader: getResources() returned " + "no resources, but getResourceAsStream() " + "returned a resource [path=" + path + ", loader=" + StringUtil.shortClassName(loader) + diff --git a/src/java/com/samskivert/util/DebugChords.java b/src/java/com/samskivert/util/DebugChords.java index d7eff3ce..1f228a65 100644 --- a/src/java/com/samskivert/util/DebugChords.java +++ b/src/java/com/samskivert/util/DebugChords.java @@ -26,10 +26,11 @@ import java.awt.event.KeyEvent; import java.util.ArrayList; -import com.samskivert.Log; import com.samskivert.util.HashIntMap; import com.samskivert.util.Tuple; +import static com.samskivert.Log.log; + /** * Provides a mechanism for causing code to be invoked when a particular * key combination is pressed in a GUI application. The code invoked is @@ -125,9 +126,7 @@ public class DebugChords tup.right.invoke(); handled = true; } catch (Throwable t) { - Log.warning("Hook failed [event=" + e + - ", hook=" + tup.right + "]."); - Log.logStackTrace(t); + log.warning("Hook failed [event=" + e + ", hook=" + tup.right + "].", t); } } } diff --git a/src/java/com/samskivert/util/DefaultLogProvider.java b/src/java/com/samskivert/util/DefaultLogProvider.java index ad75b2d5..857a2a11 100644 --- a/src/java/com/samskivert/util/DefaultLogProvider.java +++ b/src/java/com/samskivert/util/DefaultLogProvider.java @@ -73,8 +73,7 @@ public class DefaultLogProvider implements LogProvider } } - public synchronized void logStackTrace ( - int level, String moduleName, Throwable t) + public synchronized void logStackTrace (int level, String moduleName, Throwable t) { Integer tlevel = _levels.get(moduleName); if (level >= getLevel(moduleName)) { diff --git a/src/java/com/samskivert/util/FileUtil.java b/src/java/com/samskivert/util/FileUtil.java index 560fff63..0092b0e2 100644 --- a/src/java/com/samskivert/util/FileUtil.java +++ b/src/java/com/samskivert/util/FileUtil.java @@ -31,9 +31,10 @@ import java.util.jar.JarFile; import org.apache.commons.io.IOUtils; -import com.samskivert.Log; import com.samskivert.io.StreamUtil; +import static com.samskivert.Log.log; + /** * Utility methods for files. */ @@ -89,7 +90,7 @@ public class FileUtil // entries that allow us to create our directories first if (entry.isDirectory()) { if (!efile.exists() && !efile.mkdir()) { - Log.warning("Failed to create jar entry path [jar=" + jar + + log.warning("Failed to create jar entry path [jar=" + jar + ", entry=" + entry + "]."); } continue; @@ -99,7 +100,7 @@ public class FileUtil // prior to getting down and funky File parent = new File(efile.getParent()); if (!parent.exists() && !parent.mkdirs()) { - Log.warning("Failed to create jar entry parent [jar=" + jar + + log.warning("Failed to create jar entry parent [jar=" + jar + ", parent=" + parent + "]."); continue; } @@ -111,7 +112,7 @@ public class FileUtil jin = jar.getInputStream(entry); IOUtils.copy(jin, fout); } catch (Exception e) { - Log.warning("Failure unpacking [jar=" + jar + + log.warning("Failure unpacking [jar=" + jar + ", entry=" + efile + ", error=" + e + "]."); failure = true; } finally { @@ -123,7 +124,7 @@ public class FileUtil try { jar.close(); } catch (Exception e) { - Log.warning("Failed to close jar file [jar=" + jar + + log.warning("Failed to close jar file [jar=" + jar + ", error=" + e + "]."); } @@ -143,7 +144,7 @@ public class FileUtil } if (wipeMe) { if (!file.delete()) { - Log.warning("Failed to delete " + file + "."); + log.warning("Failed to delete " + file + "."); } } } diff --git a/src/java/com/samskivert/util/Interval.java b/src/java/com/samskivert/util/Interval.java index 23eda3d8..8062187f 100644 --- a/src/java/com/samskivert/util/Interval.java +++ b/src/java/com/samskivert/util/Interval.java @@ -22,7 +22,6 @@ package com.samskivert.util; import java.util.Timer; import java.util.TimerTask; -import java.util.logging.Level; import static com.samskivert.Log.log; @@ -181,7 +180,7 @@ public abstract class Interval try { expired(); } catch (Throwable t) { - log.log(Level.WARNING, "Interval broken in expired() " + this, t); + log.warning("Interval broken in expired() " + this, t); } } else { @@ -254,7 +253,7 @@ public abstract class Interval try { ival._runQueue.postRunnable(_runner); } catch (Exception e) { - log.log(Level.WARNING, "Failed to execute interval on run-queue " + + log.warning("Failed to execute interval on run-queue " + "[queue=" + ival._runQueue + ", interval=" + ival + "].", e); } } diff --git a/src/java/com/samskivert/util/Invoker.java b/src/java/com/samskivert/util/Invoker.java index f0ad601c..648781f5 100644 --- a/src/java/com/samskivert/util/Invoker.java +++ b/src/java/com/samskivert/util/Invoker.java @@ -23,7 +23,7 @@ package com.samskivert.util; import java.util.HashMap; import java.util.Iterator; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * The invoker is used to invoke self-contained units of code on an invoking thread. Each invoker @@ -192,8 +192,7 @@ public class Invoker extends LoopingThread didInvokeUnit(unit, start); } catch (Throwable t) { - Log.warning("Invocation unit failed [unit=" + unit + "]."); - Log.logStackTrace(t); + log.warning("Invocation unit failed [unit=" + unit + "].", t); } } @@ -240,7 +239,7 @@ public class Invoker extends LoopingThread // report long runners if (duration > unit.getLongThreshold()) { String howLong = (duration >= 10*unit.getLongThreshold()) ? "Really long" : "Long"; - Log.warning(howLong + " invoker unit [unit=" + unit + " (" + key + + log.warning(howLong + " invoker unit [unit=" + unit + " (" + key + "), time=" + duration + "ms]."); } } diff --git a/src/java/com/samskivert/util/LoopingThread.java b/src/java/com/samskivert/util/LoopingThread.java index c4af2001..ceca3a17 100644 --- a/src/java/com/samskivert/util/LoopingThread.java +++ b/src/java/com/samskivert/util/LoopingThread.java @@ -20,7 +20,7 @@ package com.samskivert.util; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * The looping thread provides the basic functionality for a thread that @@ -136,8 +136,7 @@ public class LoopingThread extends Thread protected void handleIterateFailure (Exception e) { // log the exception - Log.warning("LoopingThread.iterate() uncaught exception."); - Log.logStackTrace(e); + log.warning("LoopingThread.iterate() uncaught exception.", e); // and shut the thread down shutdown(); diff --git a/src/java/com/samskivert/util/ObserverList.java b/src/java/com/samskivert/util/ObserverList.java index 5f4bea28..b7b62f53 100644 --- a/src/java/com/samskivert/util/ObserverList.java +++ b/src/java/com/samskivert/util/ObserverList.java @@ -24,9 +24,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import com.samskivert.Log; import com.samskivert.util.StringUtil; +import static com.samskivert.Log.log; + /** * Provides a simplified mechanism for maintaining a list of observers (or * listeners or whatever you like to call them) and notifying those @@ -264,7 +265,7 @@ public class ObserverList extends ArrayList { // make sure we're not violating the list constraints if (!_allowDups && contains(obs)) { - Log.warning("Observer attempted to observe list it's already " + + log.warning("Observer attempted to observe list it's already " + "observing! [obs=" + obs + "]."); Thread.dumpStack(); return true; @@ -281,10 +282,8 @@ public class ObserverList extends ArrayList try { return obop.apply(obs); } catch (Throwable thrown) { - Log.warning("ObserverOp choked during notification " + - "[op=" + obop + - ", obs=" + StringUtil.safeToString(obs) + "]."); - Log.logStackTrace(thrown); + log.warning("ObserverOp choked during notification [op=" + obop + + ", obs=" + StringUtil.safeToString(obs) + "].", thrown); // if they booched it, definitely don't remove them return true; } diff --git a/src/java/com/samskivert/util/OneLineLogFormatter.java b/src/java/com/samskivert/util/OneLineLogFormatter.java index b28f244b..451b71b3 100644 --- a/src/java/com/samskivert/util/OneLineLogFormatter.java +++ b/src/java/com/samskivert/util/OneLineLogFormatter.java @@ -78,7 +78,8 @@ public class OneLineLogFormatter extends Formatter // strip the package name from the logging class where = where.substring(where.lastIndexOf(".")+1); } - boolean legacy = where.equals("Log") || where.equals("LoggingLogProvider"); + boolean legacy = where.equals("Log") || where.equals("LoggingLogProvider") || + where.startsWith("JDK14Logger$Impl"); if (legacy) { where = record.getLoggerName(); } @@ -142,10 +143,8 @@ public class OneLineLogFormatter extends Formatter protected boolean _showWhere; protected Date _date = new Date(); - protected SimpleDateFormat _format = - new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS"); - protected FieldPosition _fpos = - new FieldPosition(SimpleDateFormat.DATE_FIELD); + protected SimpleDateFormat _format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS"); + protected FieldPosition _fpos = new FieldPosition(SimpleDateFormat.DATE_FIELD); protected static String LINE_SEPARATOR = "\n"; protected static final String DATE_FORMAT = "{0,date} {0,time}"; diff --git a/src/java/com/samskivert/util/PrefsConfig.java b/src/java/com/samskivert/util/PrefsConfig.java index 325ce439..df9d6fd9 100644 --- a/src/java/com/samskivert/util/PrefsConfig.java +++ b/src/java/com/samskivert/util/PrefsConfig.java @@ -34,7 +34,7 @@ import java.util.prefs.AbstractPreferences; import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * Extends the {@link Config} mechanism to allow the modification of configuration values, which @@ -58,7 +58,7 @@ public class PrefsConfig extends Config _prefs = Preferences.userRoot().node(path); } catch (AccessControlException ace) { // security manager won't let us access prefs, no problem! - Log.info("Can't access preferences [path=" + path + "]."); + log.info("Can't access preferences [path=" + path + "]."); _prefs = new NullPreferences(); } } @@ -75,7 +75,7 @@ public class PrefsConfig extends Config _prefs = Preferences.userRoot().node(path); } catch (AccessControlException ace) { // security manager won't let us access prefs, no problem! - Log.info("Can't access preferences [path=" + path + "]."); + log.info("Can't access preferences [path=" + path + "]."); _prefs = new NullPreferences(); } } @@ -282,7 +282,7 @@ public class PrefsConfig extends Config keys.add(key); } } catch (BackingStoreException bse) { - Log.warning("Unable to enumerate preferences keys [error=" + bse + "]."); + log.warning("Unable to enumerate preferences keys [error=" + bse + "]."); } } diff --git a/src/java/com/samskivert/util/RandomUtil.java b/src/java/com/samskivert/util/RandomUtil.java index 9f011298..55ade764 100644 --- a/src/java/com/samskivert/util/RandomUtil.java +++ b/src/java/com/samskivert/util/RandomUtil.java @@ -25,7 +25,7 @@ import java.util.Iterator; import java.util.List; import java.util.Random; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * Provides miscellaneous utility routines to simplify obtaining useful random number values and to @@ -109,7 +109,7 @@ public class RandomUtil return ii; } } - Log.logStackTrace(new Throwable()); // Impossible! + log.warning("getWeightedIndex failed", new Throwable()); // Impossible! return 0; } @@ -169,7 +169,7 @@ public class RandomUtil } } - Log.logStackTrace(new Throwable()); // Impossible! + log.warning("getWeightedIndex failed", new Throwable()); // Impossible! return 0; } diff --git a/src/java/com/samskivert/util/RepeatCallTracker.java b/src/java/com/samskivert/util/RepeatCallTracker.java index 14cec71a..138ebae7 100644 --- a/src/java/com/samskivert/util/RepeatCallTracker.java +++ b/src/java/com/samskivert/util/RepeatCallTracker.java @@ -23,7 +23,7 @@ package com.samskivert.util; import java.text.SimpleDateFormat; import java.util.Date; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * A class used to debug situations where a method that should be called @@ -53,8 +53,8 @@ public class RepeatCallTracker return false; } - Log.logStackTrace(new Exception(warning)); - Log.logStackTrace(_firstCall); + log.warning(warning, new Exception()); + log.warning("First call:", _firstCall); return true; } diff --git a/src/java/com/samskivert/util/RunAnywhere.java b/src/java/com/samskivert/util/RunAnywhere.java index 42689050..45bf2186 100644 --- a/src/java/com/samskivert/util/RunAnywhere.java +++ b/src/java/com/samskivert/util/RunAnywhere.java @@ -22,7 +22,7 @@ package com.samskivert.util; import java.awt.event.InputEvent; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * Write once, run anywhere. Well, at least that's what it @@ -72,7 +72,7 @@ public class RunAnywhere if (stamp < _lastStamp) { // only warn once per time anomaly if (stamp > _lastWarning) { - Log.warning("Someone call Einstein! The clock is " + + log.warning("Someone call Einstein! The clock is " + "running backwards [dt=" + (stamp - _lastStamp) + "]."); _lastWarning = _lastStamp; diff --git a/src/java/com/samskivert/util/SerialExecutor.java b/src/java/com/samskivert/util/SerialExecutor.java index 7f7dea14..5fa710ea 100644 --- a/src/java/com/samskivert/util/SerialExecutor.java +++ b/src/java/com/samskivert/util/SerialExecutor.java @@ -22,7 +22,7 @@ package com.samskivert.util; import java.util.ArrayList; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * Executes tasks serially, but each one on a separate thread. If a task times @@ -162,7 +162,7 @@ public class SerialExecutor try { task.timedOut(); } catch (Throwable t) { - Log.logStackTrace(t); + log.warning("Unit failed", t); } checkNext(); } @@ -188,7 +188,7 @@ public class SerialExecutor _task = null; } } catch (Throwable t) { - Log.logStackTrace(t); + log.warning("Unit failed", t); } _receiver.postRunnable(new Runnable() { @@ -196,7 +196,7 @@ public class SerialExecutor try { task.resultReceived(); } catch (Throwable t) { - Log.logStackTrace(t); + log.warning("Unit failed", t); } checkNext(); } diff --git a/src/java/com/samskivert/util/tests/ArrayUtilTest.java b/src/java/com/samskivert/util/tests/ArrayUtilTest.java index af7edbbd..61beda22 100644 --- a/src/java/com/samskivert/util/tests/ArrayUtilTest.java +++ b/src/java/com/samskivert/util/tests/ArrayUtilTest.java @@ -23,10 +23,11 @@ package com.samskivert.util.tests; import junit.framework.Test; import junit.framework.TestCase; -import com.samskivert.Log; import com.samskivert.util.ArrayUtil; import com.samskivert.util.StringUtil; +import static com.samskivert.Log.log; + /** * Tests the {@link ArrayUtil} class. */ @@ -43,120 +44,120 @@ public class ArrayUtilTest extends TestCase int[] values = new int[] { 0 }; int[] work = values.clone(); ArrayUtil.reverse(work); - Log.info("reverse: " + StringUtil.toString(work)); + log.info("reverse: " + StringUtil.toString(work)); values = new int[] { 0, 1, 2 }; work = values.clone(); ArrayUtil.reverse(work); - Log.info("reverse: " + StringUtil.toString(work)); + log.info("reverse: " + StringUtil.toString(work)); work = values.clone(); ArrayUtil.reverse(work, 0, 2); - Log.info("reverse first-half: " + StringUtil.toString(work)); + log.info("reverse first-half: " + StringUtil.toString(work)); work = values.clone(); ArrayUtil.reverse(work, 1, 2); - Log.info("reverse second-half: " + StringUtil.toString(work)); + log.info("reverse second-half: " + StringUtil.toString(work)); values = new int[] { 0, 1, 2, 3, 4 }; work = values.clone(); ArrayUtil.reverse(work, 1, 3); - Log.info("reverse middle: " + StringUtil.toString(work)); + log.info("reverse middle: " + StringUtil.toString(work)); values = new int[] { 0, 1, 2, 3 }; work = values.clone(); ArrayUtil.reverse(work); - Log.info("reverse even: " + StringUtil.toString(work)); + log.info("reverse even: " + StringUtil.toString(work)); // test shuffling two elements values = new int[] { 0, 1 }; work = values.clone(); ArrayUtil.shuffle(work, 0, 1); - Log.info("first-half shuffle: " + StringUtil.toString(work)); + log.info("first-half shuffle: " + StringUtil.toString(work)); work = values.clone(); ArrayUtil.shuffle(work, 1, 1); - Log.info("second-half shuffle: " + StringUtil.toString(work)); + log.info("second-half shuffle: " + StringUtil.toString(work)); work = values.clone(); ArrayUtil.shuffle(work); - Log.info("full shuffle: " + StringUtil.toString(work)); + log.info("full shuffle: " + StringUtil.toString(work)); // test shuffling three elements values = new int[] { 0, 1, 2 }; work = values.clone(); ArrayUtil.shuffle(work, 0, 2); - Log.info("first-half shuffle: " + StringUtil.toString(work)); + log.info("first-half shuffle: " + StringUtil.toString(work)); work = values.clone(); ArrayUtil.shuffle(work, 1, 2); - Log.info("second-half shuffle: " + StringUtil.toString(work)); + log.info("second-half shuffle: " + StringUtil.toString(work)); work = values.clone(); ArrayUtil.shuffle(work); - Log.info("full shuffle: " + StringUtil.toString(work)); + log.info("full shuffle: " + StringUtil.toString(work)); // test shuffling ten elements values = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; work = values.clone(); ArrayUtil.shuffle(work, 0, 5); - Log.info("first-half shuffle: " + StringUtil.toString(work)); + log.info("first-half shuffle: " + StringUtil.toString(work)); work = values.clone(); ArrayUtil.shuffle(work, 5, 5); - Log.info("second-half shuffle: " + StringUtil.toString(work)); + log.info("second-half shuffle: " + StringUtil.toString(work)); work = values.clone(); ArrayUtil.shuffle(work); - Log.info("full shuffle: " + StringUtil.toString(work)); + log.info("full shuffle: " + StringUtil.toString(work)); // test splicing with simple truncate beyond offset values = new int[] { 0, 1, 2 }; work = values.clone(); work = ArrayUtil.splice(work, 0); - Log.info("splice truncate 0: " + StringUtil.toString(work)); + log.info("splice truncate 0: " + StringUtil.toString(work)); work = values.clone(); work = ArrayUtil.splice(work, 1); - Log.info("splice truncate 1: " + StringUtil.toString(work)); + log.info("splice truncate 1: " + StringUtil.toString(work)); work = values.clone(); work = ArrayUtil.splice(work, 2); - Log.info("splice truncate 2: " + StringUtil.toString(work)); + log.info("splice truncate 2: " + StringUtil.toString(work)); values = new int[] { 0 }; work = values.clone(); work = ArrayUtil.splice(work, 0); - Log.info("single element splice truncate 0: " + + log.info("single element splice truncate 0: " + StringUtil.toString(work)); // test splicing out a single element values = new int[] { 0, 1, 2 }; work = values.clone(); work = ArrayUtil.splice(work, 0, 1); - Log.info("splice concat 0, 1: " + StringUtil.toString(work)); + log.info("splice concat 0, 1: " + StringUtil.toString(work)); work = values.clone(); work = ArrayUtil.splice(work, 1, 1); - Log.info("splice concat 1, 1: " + StringUtil.toString(work)); + log.info("splice concat 1, 1: " + StringUtil.toString(work)); work = values.clone(); work = ArrayUtil.splice(work, 2, 1); - Log.info("splice concat 2, 1: " + StringUtil.toString(work)); + log.info("splice concat 2, 1: " + StringUtil.toString(work)); // test splicing out two elements values = new int[] { 0, 1, 2, 3 }; work = values.clone(); work = ArrayUtil.splice(work, 0, 2); - Log.info("splice concat 0, 2: " + StringUtil.toString(work)); + log.info("splice concat 0, 2: " + StringUtil.toString(work)); work = values.clone(); work = ArrayUtil.splice(work, 1, 2); - Log.info("splice concat 1, 2: " + StringUtil.toString(work)); + log.info("splice concat 1, 2: " + StringUtil.toString(work)); work = values.clone(); work = ArrayUtil.splice(work, 2, 2); - Log.info("splice concat 2, 2: " + StringUtil.toString(work)); + log.info("splice concat 2, 2: " + StringUtil.toString(work)); } public static Test suite () diff --git a/src/java/com/samskivert/velocity/Application.java b/src/java/com/samskivert/velocity/Application.java index aa3a9238..262fb31b 100644 --- a/src/java/com/samskivert/velocity/Application.java +++ b/src/java/com/samskivert/velocity/Application.java @@ -29,7 +29,6 @@ import javax.servlet.http.HttpServletRequest; import org.apache.velocity.app.Velocity; -import com.samskivert.Log; import com.samskivert.servlet.HttpErrorException; import com.samskivert.servlet.IndiscriminateSiteIdentifier; import com.samskivert.servlet.MessageManager; @@ -41,6 +40,8 @@ import com.samskivert.servlet.util.FriendlyException; import com.samskivert.servlet.util.RequestUtils; import com.samskivert.util.StringUtil; +import static com.samskivert.Log.log; + /** * The servlet API defines the concept of a web application and associates certain attributes with * it like document root and so on. This application class extends that concept by providing a base @@ -121,7 +122,7 @@ public class Application _msgmgr.activateSiteSpecificMessages(siteBundlePath, _siteLoader); } else { - Log.info("No '" + SITE_MESSAGE_BUNDLE_PATH_KEY + "' specified in servlet " + + log.info("No '" + SITE_MESSAGE_BUNDLE_PATH_KEY + "' specified in servlet " + "configuration. This is required to allow the message manager to load " + "site-specific translation resources."); } @@ -213,8 +214,7 @@ public class Application */ protected String handleException (HttpServletRequest req, Logic logic, Exception error) { - Log.warning(logic + " failed on: " + RequestUtils.reconstructURL(req)); - Log.logStackTrace(error); + log.warning(logic + " failed on: " + RequestUtils.reconstructURL(req), error); return ExceptionMap.getMessage(error); } diff --git a/src/java/com/samskivert/velocity/DispatcherServlet.java b/src/java/com/samskivert/velocity/DispatcherServlet.java index af390bc1..fb87e130 100644 --- a/src/java/com/samskivert/velocity/DispatcherServlet.java +++ b/src/java/com/samskivert/velocity/DispatcherServlet.java @@ -25,7 +25,6 @@ import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.Properties; -import java.util.logging.Level; import javax.servlet.ServletConfig; import javax.servlet.ServletException; @@ -422,7 +421,7 @@ public class DispatcherServlet extends HttpServlet public Object methodException (Class clazz, String method, Exception e) throws Exception { - log.log(Level.WARNING, "Exception [class=" + clazz.getName() + + log.warning("Exception [class=" + clazz.getName() + ", method=" + method + "].", e); return ""; } @@ -459,7 +458,7 @@ public class DispatcherServlet extends HttpServlet } } catch (Exception e) { - log.log(Level.WARNING, "doRequest failed [uri=" + request.getRequestURI() + "].", e); + log.warning("doRequest failed [uri=" + request.getRequestURI() + "].", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } } @@ -588,7 +587,7 @@ public class DispatcherServlet extends HttpServlet // nothing interesting to report } catch (Throwable t) { - log.log(Level.WARNING, "Unable to instantiate logic for application [path=" + path + + log.warning("Unable to instantiate logic for application [path=" + path + ", lclass=" + lclass + "].", t); } diff --git a/src/java/com/samskivert/velocity/SiteJarResourceLoader.java b/src/java/com/samskivert/velocity/SiteJarResourceLoader.java index 6a26df0c..f669892c 100644 --- a/src/java/com/samskivert/velocity/SiteJarResourceLoader.java +++ b/src/java/com/samskivert/velocity/SiteJarResourceLoader.java @@ -111,9 +111,9 @@ public class SiteJarResourceLoader extends ResourceLoader return (resource.getLastModified() < _loader.getLastModified(skey.siteId)); } catch (IOException ioe) { - Log.warning("Failure obtaining last modified time of " + - "site-specific jar file [siteId=" + skey.siteId + - ", error=" + ioe + "]."); + Log.log.warning("Failure obtaining last modified time of " + + "site-specific jar file [siteId=" + skey.siteId + + ", error=" + ioe + "]."); return false; } } @@ -140,9 +140,9 @@ public class SiteJarResourceLoader extends ResourceLoader try { return _loader.getLastModified(skey.siteId); } catch (IOException ioe) { - Log.warning("Failure obtaining last modified time of " + - "site-specific jar file [siteId=" + skey.siteId + - ", error=" + ioe + "]."); + Log.log.warning("Failure obtaining last modified time of " + + "site-specific jar file [siteId=" + skey.siteId + + ", error=" + ioe + "]."); return 0; } } diff --git a/src/java/com/samskivert/velocity/SiteKey.java b/src/java/com/samskivert/velocity/SiteKey.java index 582e6ed8..969d6926 100644 --- a/src/java/com/samskivert/velocity/SiteKey.java +++ b/src/java/com/samskivert/velocity/SiteKey.java @@ -20,7 +20,7 @@ package com.samskivert.velocity; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * Decodes a compound Velocity resource name plus site identifier. @@ -43,7 +43,7 @@ public class SiteKey try { siteId = Integer.parseInt(path.substring(0, cidx)); } catch (Exception e) { - Log.warning("Invalid site path [path=" + path + "]."); + log.warning("Invalid site path [path=" + path + "]."); } this.path = path.substring(cidx+1); } diff --git a/src/java/com/samskivert/velocity/SiteResourceManager.java b/src/java/com/samskivert/velocity/SiteResourceManager.java index 03a9cea4..df31c3c0 100644 --- a/src/java/com/samskivert/velocity/SiteResourceManager.java +++ b/src/java/com/samskivert/velocity/SiteResourceManager.java @@ -31,7 +31,6 @@ import org.apache.velocity.runtime.resource.ResourceManagerImpl; import org.apache.velocity.runtime.resource.loader.ResourceLoader; import com.samskivert.Log; - import com.samskivert.servlet.SiteIdentifier; import com.samskivert.servlet.SiteResourceLoader; diff --git a/src/java/com/samskivert/velocity/VelocityUtil.java b/src/java/com/samskivert/velocity/VelocityUtil.java index 4c7a0238..136d2539 100644 --- a/src/java/com/samskivert/velocity/VelocityUtil.java +++ b/src/java/com/samskivert/velocity/VelocityUtil.java @@ -26,7 +26,7 @@ import org.apache.velocity.runtime.RuntimeServices; import org.apache.velocity.runtime.log.LogChute; import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * Handy Velocity-related routines. @@ -83,22 +83,14 @@ public class VelocityUtil // nothing doing } public void log (int level, String message) { - switch (level) { - case ERROR_ID: - case WARN_ID: - Log.warning(message); - break; - default: - case INFO_ID: - case DEBUG_ID: - // velocity insists on sending info and debug messages even - // though isLevelEnabled() returns false - break; + if (level == ERROR_ID || level == WARN_ID) { + log.warning(message); } } public void log (int level, String message, Throwable t) { - log(level, message); - Log.logStackTrace(t); + if (level == ERROR_ID || level == WARN_ID) { + log.warning(message, t); + } } public boolean isLevelEnabled (int level) { return (level == WARN_ID || level == ERROR_ID); diff --git a/src/java/com/samskivert/xml/CheckVersionRule.java b/src/java/com/samskivert/xml/CheckVersionRule.java index 916f9b1a..a7b159a3 100644 --- a/src/java/com/samskivert/xml/CheckVersionRule.java +++ b/src/java/com/samskivert/xml/CheckVersionRule.java @@ -22,7 +22,7 @@ package com.samskivert.xml; import org.apache.commons.digester.Rule; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * Used to compare a file format version number in an XML file with the @@ -52,7 +52,7 @@ public class CheckVersionRule extends Rule { int version = Integer.parseInt(bodyText.trim()); if (version > _version) { - Log.warning(_parserIdentifier + " only knows about version " + + log.warning(_parserIdentifier + " only knows about version " + _version + ", but is being asked to parse a file " + "with version " + version + ". Wackiness may ensue."); } diff --git a/src/java/com/samskivert/xml/SimpleParser.java b/src/java/com/samskivert/xml/SimpleParser.java index 1ae08994..9dc29efd 100644 --- a/src/java/com/samskivert/xml/SimpleParser.java +++ b/src/java/com/samskivert/xml/SimpleParser.java @@ -26,7 +26,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.xml.sax.*; import org.xml.sax.helpers.DefaultHandler; -import com.samskivert.Log; +import static com.samskivert.Log.log; /** * The simple parser class provides an extensible object that is @@ -119,7 +119,7 @@ public class SimpleParser extends DefaultHandler try { return (val == null) ? -1 : Integer.parseInt(val); } catch (NumberFormatException nfe) { - Log.warning("Malformed integer value [val=" + val + "]."); + log.warning("Malformed integer value [val=" + val + "]."); return -1; } }