Skip to content

Commit

Permalink
replaced %s and %d in log statements with {}
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Jan 16, 2012
1 parent c106e51 commit 8b5662c
Show file tree
Hide file tree
Showing 84 changed files with 281 additions and 275 deletions.
Expand Up @@ -148,7 +148,7 @@ protected void waitForAvailableDatabase() {
success = true;
} catch (Exception ex) {
log.error(
"Could not get a connection to the database: %s. Waiting for 10 seconds before trying to connect to the database again.",
"Could not get a connection to the database: {}. Waiting for 10 seconds before trying to connect to the database again.",
ex.getMessage());
AppUtils.sleep(10000);
} finally {
Expand Down
Expand Up @@ -46,17 +46,17 @@ protected boolean createTablesIfNecessary() {
+ parameterService.getTablePrefix() + "_trigger_hist") + 1;
platform.getSqlTemplate().update("alter table " + parameterService.getTablePrefix()
+ "_trigger_hist alter column trigger_hist_id restart with " + triggerHistId);
log.info("Resetting auto increment columns for %s", parameterService.getTablePrefix() + "_trigger_hist");
log.info("Resetting auto increment columns for {}", parameterService.getTablePrefix() + "_trigger_hist");
long outgoingBatchId = platform.getSqlTemplate().queryForLong("select max(batch_id) from "
+ parameterService.getTablePrefix() + "_outgoing_batch") + 1;
platform.getSqlTemplate().update("alter table " + parameterService.getTablePrefix()
+ "_outgoing_batch alter column batch_id restart with " + outgoingBatchId);
log.info("Resetting auto increment columns for %s", parameterService.getTablePrefix() + "_outgoing_batch");
log.info("Resetting auto increment columns for {}", parameterService.getTablePrefix() + "_outgoing_batch");
long dataId = platform.getSqlTemplate().queryForLong("select max(data_id) from " + parameterService.getTablePrefix()
+ "_data") + 1;
platform.getSqlTemplate().update("alter table " + parameterService.getTablePrefix()
+ "_data alter column data_id restart with " + dataId);
log.info("Resetting auto increment columns for %s", parameterService.getTablePrefix() + "_data");
log.info("Resetting auto increment columns for {}", parameterService.getTablePrefix() + "_data");
}
return tablesCreated;
}
Expand Down Expand Up @@ -120,4 +120,4 @@ protected String getDbSpecificDataHasChangedCondition(Trigger trigger) {
return "var_row_data != var_old_data";
}

}
}
Expand Up @@ -47,7 +47,7 @@ protected void initTablesAndFunctionsForSpecificDialect() {
transaction.commit();
} catch (Exception e) {
try {
log.info("Creating environment variables %s and %s", SYNC_TRIGGERS_DISABLED_USER_VARIABLE,
log.info("Creating environment variables {} and {}", SYNC_TRIGGERS_DISABLED_USER_VARIABLE,
SYNC_TRIGGERS_DISABLED_NODE_VARIABLE);
new SqlScript(getSqlScriptUrl(), getPlatform().getSqlTemplate(), ";").execute();
} catch (Exception ex) {
Expand Down Expand Up @@ -83,4 +83,4 @@ public String getSourceNodeExpression() {
return SYNC_TRIGGERS_DISABLED_NODE_VARIABLE;
}

}
}
Expand Down
Expand Up @@ -119,4 +119,4 @@ public void truncateTable(String tableName) {
platform.getSqlTemplate().update("delete from " + tableName);
}

}
}
Expand Down
Expand Up @@ -68,14 +68,14 @@ public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String sc
try {
int count = platform.getSqlTemplate().update(dropSql);
if (count > 0) {
log.info("Just dropped trigger %s", triggerName);
log.info("Just dropped trigger {}", triggerName);
}
count = platform.getSqlTemplate().update(dropTable);
if (count > 0) {
log.info("Just dropped table %s_CONFIG", triggerName);
log.info("Just dropped table {}_CONFIG", triggerName);
}
} catch (Exception e) {
log.warn("Error removing %s: %s", triggerName, e.getMessage());
log.warn("Error removing {}: {}", triggerName, e.getMessage());
}
}
}
Expand Down Expand Up @@ -123,4 +123,4 @@ public boolean supportsTransactionId() {
return true;
}

}
}
Expand Down
Expand Up @@ -92,18 +92,18 @@ public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String sc
try {
int count = platform.getSqlTemplate().update(dropSql);
if (count > 0) {
log.info("Just dropped trigger %s", triggerName);
log.info("Just dropped trigger {}", triggerName);
}
} catch (Exception e) {
log.warn("Error removing %s: %s", triggerName, e.getMessage());
log.warn("Error removing {}: {}", triggerName, e.getMessage());
}
try {
int count = platform.getSqlTemplate().update(dropTable);
if (count > 0) {
log.info("Just dropped table %s_CONFIG", triggerName);
log.info("Just dropped table {}_CONFIG", triggerName);
}
} catch (Exception e) {
log.warn("Error removing %s: %s", triggerName, e.getMessage());
log.warn("Error removing {}: {}", triggerName, e.getMessage());
}
}
}
Expand Down Expand Up @@ -173,4 +173,4 @@ public boolean canGapsOccurInCapturedDataIds() {
return false;
}

}
}
Expand Down
Expand Up @@ -58,10 +58,10 @@ public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String sc
try {
int count = platform.getSqlTemplate().update(dropSql);
if (count > 0) {
log.info("Just dropped trigger %s", triggerName);
log.info("Just dropped trigger {}", triggerName);
}
} catch (Exception e) {
log.warn("Error removing %s: %s", triggerName, e.getMessage());
log.warn("Error removing {}: {}", triggerName, e.getMessage());
}
}
}
Expand Down Expand Up @@ -128,4 +128,4 @@ public boolean canGapsOccurInCapturedDataIds() {
return false;
}

}
}
Expand Up @@ -60,7 +60,7 @@ protected void initTablesAndFunctionsForSpecificDialect() {
platform.getSqlTemplate().queryForInt("select count(*) from " + contextTableName);
} catch (Exception e) {
try {
log.info("Creating global temporary table %s", contextTableName);
log.info("Creating global temporary table {}", contextTableName);
platform.getSqlTemplate().update(String.format(CONTEXT_TABLE_CREATE, contextTableName));
} catch (Exception ex) {
log.error("Error while initializing Interbase dialect", ex);
Expand Down Expand Up @@ -171,6 +171,6 @@ public void cleanupTriggers() {
for (String name : names) {
count += platform.getSqlTemplate().update("drop trigger " + name);
}
log.info("Remove %d triggers", count);
log.info("Remove {} triggers", count);
}
}
Expand Up @@ -74,7 +74,7 @@ public Boolean execute(Connection con) throws SQLException {
stmt = con.createStatement();
stmt.execute(sql);
} catch (Exception e) {
log.warn("Error removing %s: %s", triggerName, e.getMessage());
log.warn("Error removing {}: {}", triggerName, e.getMessage());
} finally {
if (catalogName != null) {
con.setCatalog(previousCatalog);
Expand Down Expand Up @@ -185,4 +185,4 @@ public boolean needsToSelectLobData() {
return true;
}

}
}
Expand Up @@ -83,7 +83,7 @@ protected void createRequiredFunctions() {
platform.getSqlTemplate().update(
triggerText.getFunctionSql(functions[i], funcName,
platform.getDefaultSchema()));
log.info("Just installed %s", funcName);
log.info("Just installed {}", funcName);
}
}
}
Expand Down Expand Up @@ -176,4 +176,4 @@ public BinaryEncoding getBinaryEncoding() {
protected String getDbSpecificDataHasChangedCondition(Trigger trigger) {
return "var_row_data != var_old_data";
}
}
}
Expand Up @@ -227,4 +227,4 @@ protected String getDbSpecificDataHasChangedCondition(Trigger trigger) {
}
}

}
}
Expand Up @@ -141,4 +141,4 @@ public BinaryEncoding getBinaryEncoding() {
return BinaryEncoding.BASE64;
}

}
}
Expand Up @@ -75,7 +75,7 @@ public Boolean execute(Connection con) throws SQLException {
stmt = con.createStatement();
stmt.execute(sql);
} catch (Exception e) {
log.warn("Error removing %s: %s", triggerName, e.getMessage());
log.warn("Error removing {}: {}", triggerName, e.getMessage());
} finally {
if (catalogName != null) {
con.setCatalog(previousCatalog);
Expand Down Expand Up @@ -182,4 +182,4 @@ public boolean needsToSelectLobData() {
return true;
}

}
}
Expand Up @@ -351,4 +351,4 @@ public String encryptText(String plainText) throws Exception {
return "";
}

}
}
Expand Up @@ -22,6 +22,7 @@ public static void main(String[] args) throws Exception {
}

protected static boolean refactor(StringBuilder contents) {
boolean refactored = false;
String[] lines = contents.toString().split("\n");
contents.setLength(0);
int logmode = 0;
Expand All @@ -31,14 +32,19 @@ protected static boolean refactor(StringBuilder contents) {
}

if (!line.contains("String.format") && logmode > 0) {
refactored = true;
line = line.replace("%s", "{}");
line = line.replace("%d", "{}");
logmode--;
} else {
logmode =0;
}

contents.append(line);
contents.append("\n");

}
return true;
contents.substring(0, contents.length()-1);
return refactored;
}
}
}
Expand Up @@ -305,11 +305,11 @@ public synchronized boolean start(boolean startJobs) {
Node node = nodeService.findIdentity();
if (node != null) {
log.info(
"Starting registered node [group=%s, id=%s, externalId=%s]",
"Starting registered node [group={}, id={}, externalId={}]",
new Object[] { node.getNodeGroupId(), node.getNodeId(),
node.getExternalId() });
} else {
log.info("Starting unregistered node [group=%s, externalId=%s]",
log.info("Starting unregistered node [group={}, externalId={}]",
parameterService.getNodeGroupId(), parameterService.getExternalId());
}
triggerRouterService.syncTriggers();
Expand All @@ -329,7 +329,7 @@ public synchronized boolean start(boolean startJobs) {
}

log.info(
"SymmetricDS: type=%s, name=%s, version=%s, groupId=%s, externalId=%s, databaseName=%s, databaseVersion=%s, driverName=%s, driverVersion=%s",
"SymmetricDS: type={}, name={}, version={}, groupId={}, externalId={}, databaseName={}, databaseVersion={}, driverName={}, driverVersion={}",
new Object[] { getDeploymentType().getDeploymentType(), getEngineName(),
Version.version(), getParameterService().getNodeGroupId(),
getParameterService().getExternalId(), symmetricDialect.getName(),
Expand All @@ -339,7 +339,7 @@ public synchronized boolean start(boolean startJobs) {
}

public synchronized void stop() {
log.info("Closing SymmetricDS externalId=%s version=%s database=%s",
log.info("Closing SymmetricDS externalId={} version={} database={}",
new Object[] { getParameterService().getExternalId(), Version.version(),
symmetricDialect.getName() });
if (jobManager != null) {
Expand Down Expand Up @@ -425,7 +425,7 @@ public boolean isConfigured() {
} else if (!isSelfConfigurable && node == null
&& StringUtils.isBlank(getParameterService().getRegistrationUrl())) {
log.warn(
"Please set the property %s so this node may pull registration or manually insert configuration into the configuration tables",
"Please set the property {} so this node may pull registration or manually insert configuration into the configuration tables",
ParameterConstants.REGISTRATION_URL);
} else if (Constants.PLEASE_SET_ME.equals(getParameterService().getExternalId())
|| Constants.PLEASE_SET_ME.equals(registrationUrl)
Expand All @@ -435,7 +435,7 @@ public boolean isConfigured() {
&& (!node.getExternalId().equals(getParameterService().getExternalId()) || !node
.getNodeGroupId().equals(getParameterService().getNodeGroupId()))) {
log.warn(
"The configured state does not match recorded database state. The recorded external id is %s while the configured external id is %s. The recorded node group id is %s while the configured node group id is %s",
"The configured state does not match recorded database state. The recorded external id is {} while the configured external id is {}. The recorded node group id is {} while the configured node group id is {}",
new Object[] { node.getExternalId(), getParameterService().getExternalId(),
node.getNodeGroupId(), getParameterService().getNodeGroupId() });

Expand All @@ -448,7 +448,7 @@ public boolean isConfigured() {
// Offline node detection is not disabled (-1) and the value is too
// small (less than the heartbeat)
log.warn(
"The %s property must be a longer period of time than the %s property. Otherwise, nodes will be taken offline before the heartbeat job has a chance to run",
"The {} property must be a longer period of time than the {} property. Otherwise, nodes will be taken offline before the heartbeat job has a chance to run",
ParameterConstants.OFFLINE_NODE_DETECTION_PERIOD_MINUTES,
ParameterConstants.HEARTBEAT_SYNC_ON_PUSH_PERIOD_SEC);

Expand Down
Expand Up @@ -106,7 +106,7 @@ public AbstractSymmetricDialect(IParameterService parameterService,
this.parameterService = parameterService;
this.platform = platform;

log.info("The DbDialect being used is %s", this.getClass().getName());
log.info("The DbDialect being used is {}", this.getClass().getName());

ISqlTemplate sqlTemplate = this.platform.getSqlTemplate();
this.databaseMajorVersion = sqlTemplate.getDatabaseMajorVersion();
Expand Down Expand Up @@ -183,7 +183,7 @@ protected void createRequiredFunctions() {
this.platform.getSqlTemplate().update(
triggerText.getFunctionSql(functions[i], funcName,
platform.getDefaultSchema()));
log.info("Just installed %s", funcName);
log.info("Just installed {}", funcName);
}
}
}
Expand Down Expand Up @@ -270,7 +270,7 @@ final protected void logSql(String sql, StringBuilder sqlBuffer) {
public void createTrigger(final StringBuilder sqlBuffer, final DataEventType dml,
final Trigger trigger, final TriggerHistory hist, final Channel channel,
final String tablePrefix, final Table table) {
log.info("Creating %s trigger for %s", hist.getTriggerNameForDmlType(dml),
log.info("Creating {} trigger for {}", hist.getTriggerNameForDmlType(dml),
trigger.getSourceTableName());

String previousCatalog = null;
Expand All @@ -291,18 +291,18 @@ public void createTrigger(final StringBuilder sqlBuffer, final DataEventType dml
previousCatalog = switchCatalogForTriggerInstall(sourceCatalogName, transaction);

try {
log.debug("Running: %s", triggerSql);
log.debug("Running: {}", triggerSql);
transaction.execute(triggerSql);
} catch (SqlException ex) {
log.error("Failed to create trigger: %s", triggerSql);
log.error("Failed to create trigger: {}", triggerSql);
throw ex;
}

if (StringUtils.isNotBlank(postTriggerDml)) {
try {
transaction.execute(postTriggerDml);
} catch (SqlException ex) {
log.error("Failed to create post trigger: %s", postTriggerDml);
log.error("Failed to create post trigger: {}", postTriggerDml);
throw ex;
}
}
Expand Down Expand Up @@ -468,7 +468,7 @@ protected boolean createTablesIfNecessary() {
String alterSql = builder.alterDatabase(modelFromDatabase, modelFromXml);

if (log.isDebugEnabled()) {
log.debug("Alter SQL Generated: %s", alterSql);
log.debug("Alter SQL Generated: {}", alterSql);
}
new SqlScript(alterSql, getPlatform().getSqlTemplate(), true, delimiter, null)
.execute();
Expand Down Expand Up @@ -794,4 +794,4 @@ protected void close(ISqlTransaction transaction) {
public String getTablePrefix() {
return parameterService.getTablePrefix();
}
}
}
Expand Up @@ -931,4 +931,4 @@ public String toString() {
}

}
}
}

0 comments on commit 8b5662c

Please sign in to comment.