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