Skip to content

Commit

Permalink
First pass at Symmetric Logger with internationalization.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhanes committed Aug 15, 2009
1 parent 58d0535 commit f89f280
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
Expand Up @@ -133,51 +133,58 @@ public void info(String messageKey, Throwable t, Object... args) {

public void warn(String messageKey) {
if (logger.isWarnEnabled()) {
logger.info(getMessage(messageKey));
logger.warn(getMessage(messageKey));
}
}

public void warn(String messageKey, Throwable t) {
if (logger.isWarnEnabled()) {
logger.info(getMessage(messageKey), t);
logger.warn(getMessage(messageKey), t);
}
}

public void warn(String messageKey, Object... args) {
if (logger.isWarnEnabled()) {
logger.info(getMessage(messageKey, args));
logger.warn(getMessage(messageKey, args));
}
}

public void warn(String messageKey, Throwable t, Object... args) {
if (logger.isWarnEnabled()) {
logger.info(getMessage(messageKey, args), t);
logger.warn(getMessage(messageKey, args), t);
}
}

// error

public void error(String messageKey) {
if (logger.isErrorEnabled()) {
logger.info(getMessage(messageKey));
logger.error(getMessage(messageKey));
}
}

public void error(String messageKey, Throwable t) {
if (logger.isErrorEnabled()) {
logger.info(getMessage(messageKey), t);
logger.error(getMessage(messageKey), t);
}
}

public void error(String messageKey, Object... args) {
if (logger.isErrorEnabled()) {
logger.info(getMessage(messageKey, args));
logger.error(getMessage(messageKey, args));
}
}

public void error(String messageKey, Throwable t, Object... args) {
if (logger.isErrorEnabled()) {
logger.info(getMessage(messageKey, args), t);
logger.error(getMessage(messageKey, args), t);
}
}


public void error(Throwable t) {
if (logger.isErrorEnabled()) {
logger.error(t,t);
}
}

Expand Down
Expand Up @@ -33,13 +33,13 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.FastDateFormat;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ddlutils.model.Column;
import org.apache.ddlutils.model.Table;
import org.jumpmind.symmetric.SymmetricEngine;
import org.jumpmind.symmetric.common.Constants;
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.common.logging.Log;
import org.jumpmind.symmetric.common.logging.LogFactory;
import org.jumpmind.symmetric.db.IDbDialect;
import org.jumpmind.symmetric.model.DataEventType;
import org.jumpmind.symmetric.model.Trigger;
Expand Down Expand Up @@ -81,11 +81,10 @@ protected boolean initialize(DataEventType triggerType, String tableName) {
this.nodeService = getNodeService(engine);
this.dbDialect = getDbDialect(engine);
this.triggerHistory = triggerService.getHistoryRecordFor(getTriggerHistId());
this.trigger = triggerService.getActiveTriggersForSourceNodeGroup(parameterService
.getString(ParameterConstants.NODE_GROUP_ID), true).get(triggerHistory.getTriggerId());
this.trigger = triggerService.getActiveTriggersForSourceNodeGroup(
parameterService.getString(ParameterConstants.NODE_GROUP_ID), true).get(triggerHistory.getTriggerId());
if (trigger == null) {
logger.warn(String.format("Could not find an %s trigger in the cache for table %s and a hist id of %s.",
triggerType.name(), tableName, getTriggerHistId()));
logger.warn(String.format("TriggerMissing", triggerType.name(), tableName, getTriggerHistId()));
return false;
}
this.table = dbDialect.getMetaDataFor(null, trigger.getSourceSchemaName(), tableName, true);
Expand Down
Expand Up @@ -20,10 +20,10 @@

package org.jumpmind.symmetric.db.hsqldb;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ddlutils.model.Table;
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.common.logging.Log;
import org.jumpmind.symmetric.common.logging.LogFactory;
import org.jumpmind.symmetric.db.AbstractDbDialect;
import org.jumpmind.symmetric.db.BinaryEncoding;
import org.jumpmind.symmetric.db.IDbDialect;
Expand Down Expand Up @@ -108,7 +108,7 @@ protected boolean doesTriggerExistOnPlatform(String catalogName, String schema,
"select count(*) from INFORMATION_SCHEMA.SYSTEM_TRIGGERS where trigger_name = ?",
new Object[] { triggerName }) > 0;
}

@Override
public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String schemaName, String triggerName,
String tableName, TriggerHistory oldHistory) {
Expand All @@ -121,7 +121,7 @@ public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String sc
try {
jdbcTemplate.update(dropSql);
} catch (Exception e) {
logger.warn("Error removing " + triggerName + ": " + e.getMessage());
logger.warn("TriggerDropError", triggerName, e.getMessage());
}
}
}
Expand Down
Expand Up @@ -25,8 +25,6 @@
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hsqldb.Token;
import org.hsqldb.types.Binary;
import org.jumpmind.symmetric.model.Data;
Expand Down Expand Up @@ -62,17 +60,18 @@ public void fire(int type, String triggerName, String tableName, Object[] oldRow
}
}
} catch (RuntimeException ex) {
logger.error(ex, ex);
logger.error(ex);
throw ex;
} finally {
lastTransactionIdUpdate = System.currentTimeMillis();
}
}

protected Data createData(Object[] oldRow, Object[] newRow) {
Data data = new Data(StringUtils.isBlank(trigger.getTargetTableName()) ? tableName : trigger
.getTargetTableName(), triggerType, formatRowData(oldRow, newRow), formatPkRowData(oldRow, newRow),
triggerHistory, trigger.getChannelId(), getTransactionId(oldRow, newRow), getDbDialect().getSyncNodeDisabled());
triggerHistory, trigger.getChannelId(), getTransactionId(oldRow, newRow), getDbDialect()
.getSyncNodeDisabled());
if (triggerType == DataEventType.UPDATE && trigger.isSyncColumnLevel()) {
data.setOldData(formatAsCsv(getOrderedColumnValues(oldRow)));
}
Expand All @@ -95,7 +94,7 @@ private void init(int type, String triggerName, String tableName) {
buildDataSelectSql();
buildTransactionIdSql();
if (logger.isDebugEnabled()) {
logger.debug("initializing " + triggerName + " for " + triggerType);
logger.debug("TriggerInitializing", triggerName, triggerType);
}
initialized = true;
}
Expand Down

0 comments on commit f89f280

Please sign in to comment.