[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, dbname, created. v0.9.18-100-g13148e6
added by portage for gitosis-gentoo
git-noreply at pixie.qos.ch
Thu Mar 18 23:56:17 CET 2010
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, dbname has been created
at 13148e6ffc936dfafa2888c1bdb20f097494357e (commit)
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=13148e6ffc936dfafa2888c1bdb20f097494357e
http://github.com/ceki/logback/commit/13148e6ffc936dfafa2888c1bdb20f097494357e
commit 13148e6ffc936dfafa2888c1bdb20f097494357e
Merge: ea6065c 35a2ffe
Author: Ceki Gulcu <ceki at qos.ch>
Date: Thu Mar 18 23:54:24 2010 +0100
- Merge branch 'master' of http://github.com/nurkiewicz/logback into dbname
- plus ceki's simplifications
diff --cc logback-classic/src/main/java/ch/qos/logback/classic/db/SQLBuilder.java
index 0000000,9c197a0..1390237
mode 000000,100644..100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/db/SQLBuilder.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/SQLBuilder.java
@@@ -1,0 -1,47 +1,60 @@@
++/**
++ * Logback: the reliable, generic, fast and flexible logging framework.
++ * Copyright (C) 1999-2010, QOS.ch. All rights reserved.
++ *
++ * This program and the accompanying materials are dual-licensed under either
++ * the terms of the Eclipse Public License v1.0 as published by the Eclipse
++ * Foundation
++ *
++ * or (per the licensee's choosing)
++ *
++ * under the terms of the GNU Lesser General Public License version 2.1 as
++ * published by the Free Software Foundation.
++ */
+ package ch.qos.logback.classic.db;
+
+ import ch.qos.logback.classic.db.names.*;
+
+ /**
+ * @author Tomasz Nurkiewicz
+ * @since 2010-03-16
+ */
+ public class SQLBuilder {
+
+ static String buildInsertPropertiesSQL(DBNameResolver dbNameResolver) {
+ StringBuilder sqlBuilder = new StringBuilder("INSERT INTO ");
+ sqlBuilder.append(dbNameResolver.getTableName(TableName.LOGGING_EVENT_PROPERTY)).append(" (");
- sqlBuilder.append(dbNameResolver.getLoggingEventPropertyColumnName(LoggingEventPropertyColumnName.EVENT_ID)).append(",");
- sqlBuilder.append(dbNameResolver.getLoggingEventPropertyColumnName(LoggingEventPropertyColumnName.MAPPED_KEY)).append(",");
- sqlBuilder.append(dbNameResolver.getLoggingEventPropertyColumnName(LoggingEventPropertyColumnName.MAPPED_VALUE)).append(") ");
++ sqlBuilder.append(dbNameResolver.getColumnName(ColumnName.EVENT_ID)).append(",");
++ sqlBuilder.append(dbNameResolver.getColumnName(ColumnName.MAPPED_KEY)).append(",");
++ sqlBuilder.append(dbNameResolver.getColumnName(ColumnName.MAPPED_VALUE)).append(") ");
+ sqlBuilder.append("VALUES (?, ?, ?)");
+ return sqlBuilder.toString();
+ }
+
+ static String buildInsertExceptionSQL(DBNameResolver dbNameResolver) {
+ StringBuilder sqlBuilder = new StringBuilder("INSERT INTO ");
+ sqlBuilder.append(dbNameResolver.getTableName(TableName.LOGGING_EVENT_EXCEPTION)).append(" (");
- sqlBuilder.append(dbNameResolver.getLoggingEventExceptionColumnName(LoggingEventExceptionColumnName.EVENT_ID)).append(",");
- sqlBuilder.append(dbNameResolver.getLoggingEventExceptionColumnName(LoggingEventExceptionColumnName.I)).append(",");
- sqlBuilder.append(dbNameResolver.getLoggingEventExceptionColumnName(LoggingEventExceptionColumnName.TRACE_LINE)).append(") ");
++ sqlBuilder.append(dbNameResolver.getColumnName(ColumnName.EVENT_ID)).append(",");
++ sqlBuilder.append(dbNameResolver.getColumnName(ColumnName.I)).append(",");
++ sqlBuilder.append(dbNameResolver.getColumnName(ColumnName.TRACE_LINE)).append(") ");
+ sqlBuilder.append("VALUES (?, ?, ?)");
+ return sqlBuilder.toString();
+ }
+
+ static String buildInsertSQL(DBNameResolver dbNameResolver) {
+ StringBuilder sqlBuilder = new StringBuilder("INSERT INTO ");
+ sqlBuilder.append(dbNameResolver.getTableName(TableName.LOGGING_EVENT)).append(" (");
- sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.TIMESTMP)).append(", ");
- sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.FORMATTED_MESSAGE)).append(", ");
- sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.LOGGER_NAME)).append(", ");
- sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.LEVEL_STRING)).append(", ");
- sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.THREAD_NAME)).append(", ");
- sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.REFERENCE_FLAG)).append(", ");
- sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.CALLER_FILENAME)).append(", ");
- sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.CALLER_CLASS)).append(", ");
- sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.CALLER_METHOD)).append(", ");
- sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.CALLER_LINE)).append(") ");
++ sqlBuilder.append(dbNameResolver.getColumnName(ColumnName.TIMESTMP)).append(", ");
++ sqlBuilder.append(dbNameResolver.getColumnName(ColumnName.FORMATTED_MESSAGE)).append(", ");
++ sqlBuilder.append(dbNameResolver.getColumnName(ColumnName.LOGGER_NAME)).append(", ");
++ sqlBuilder.append(dbNameResolver.getColumnName(ColumnName.LEVEL_STRING)).append(", ");
++ sqlBuilder.append(dbNameResolver.getColumnName(ColumnName.THREAD_NAME)).append(", ");
++ sqlBuilder.append(dbNameResolver.getColumnName(ColumnName.REFERENCE_FLAG)).append(", ");
++ sqlBuilder.append(dbNameResolver.getColumnName(ColumnName.CALLER_FILENAME)).append(", ");
++ sqlBuilder.append(dbNameResolver.getColumnName(ColumnName.CALLER_CLASS)).append(", ");
++ sqlBuilder.append(dbNameResolver.getColumnName(ColumnName.CALLER_METHOD)).append(", ");
++ sqlBuilder.append(dbNameResolver.getColumnName(ColumnName.CALLER_LINE)).append(") ");
+ sqlBuilder.append(" VALUES (?, ?, ? ,?, ?, ?, ?, ?, ?, ?)");
+ return sqlBuilder.toString();
+ }
+ }
diff --cc logback-classic/src/main/java/ch/qos/logback/classic/db/names/ColumnName.java
index 0000000,0000000..2717331
new file mode 100644
--- /dev/null
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/ColumnName.java
@@@ -1,0 -1,0 +1,24 @@@
++package ch.qos.logback.classic.db.names;
++
++public enum ColumnName {
++
++ EVENT_ID,
++
++ TIMESTMP,
++ FORMATTED_MESSAGE,
++ LOGGER_NAME,
++ LEVEL_STRING,
++ THREAD_NAME,
++ REFERENCE_FLAG,
++ CALLER_FILENAME,
++ CALLER_CLASS,
++ CALLER_METHOD,
++ CALLER_LINE,
++
++ // MDC
++ MAPPED_KEY,
++ MAPPED_VALUE,
++
++ I,
++ TRACE_LINE;
++}
diff --cc logback-classic/src/main/java/ch/qos/logback/classic/db/names/CustomDBNameResolver.java
index 0000000,0880aa5..e0578f9
mode 000000,100644..100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/CustomDBNameResolver.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/CustomDBNameResolver.java
@@@ -1,0 -1,118 +1,52 @@@
++/**
++ * Logback: the reliable, generic, fast and flexible logging framework.
++ * Copyright (C) 1999-2010, QOS.ch. All rights reserved.
++ *
++ * This program and the accompanying materials are dual-licensed under either
++ * the terms of the Eclipse Public License v1.0 as published by the Eclipse
++ * Foundation
++ *
++ * or (per the licensee's choosing)
++ *
++ * under the terms of the GNU Lesser General Public License version 2.1 as
++ * published by the Free Software Foundation.
++ */
+ package ch.qos.logback.classic.db.names;
+
-import java.util.EnumMap;
++import java.util.HashMap;
+ import java.util.Map;
+
+ /**
+ * @author Tomasz Nurkiewicz
+ * @since 2010-03-16
+ */
+ public class CustomDBNameResolver implements DBNameResolver {
+
+ private final DBNameResolver defaultDbNameResolver = new DefaultDBNameResolver();
- private final Map<TableName, String> tableNameOverrides = new EnumMap<TableName, String>(TableName.class);
- private final Map<LoggingEventColumnName, String> leColumnNameOverrides = new EnumMap<LoggingEventColumnName, String>(LoggingEventColumnName.class);
- private final Map<LoggingEventPropertyColumnName, String> lePropertyColumnNameOverrides = new EnumMap<LoggingEventPropertyColumnName, String>(LoggingEventPropertyColumnName.class);
- private final Map<LoggingEventExceptionColumnName, String> leExceptionColumnNameOverrides = new EnumMap<LoggingEventExceptionColumnName, String>(LoggingEventExceptionColumnName.class);
-
- public String getTableName(TableName tableName) {
++ private final Map<String, String> tableNameOverrides = new HashMap<String, String>();
++ private final Map<String, String> columnNameOverrides = new HashMap<String, String>();
++
++ public <N extends Enum<?>> String getTableName(N tableName) {
+ if (tableNameOverrides.get(tableName) != null)
+ return tableNameOverrides.get(tableName);
+ return defaultDbNameResolver.getTableName(tableName);
+ }
+
- public String getLoggingEventColumnName(LoggingEventColumnName columnName) {
- if (leColumnNameOverrides.get(columnName) != null)
- return leColumnNameOverrides.get(columnName);
- return defaultDbNameResolver.getLoggingEventColumnName(columnName);
++ public <N extends Enum<?>> String getColumnName(N columnName) {
++ if (columnNameOverrides.get(columnName) != null)
++ return columnNameOverrides.get(columnName);
++ return defaultDbNameResolver.getColumnName(columnName);
+ }
-
- public String getLoggingEventPropertyColumnName(LoggingEventPropertyColumnName columnName) {
- if (lePropertyColumnNameOverrides.get(columnName) != null)
- return lePropertyColumnNameOverrides.get(columnName);
- return defaultDbNameResolver.getLoggingEventPropertyColumnName(columnName);
++
++
++ public void overrideTableName(String reference, String name) {
++ tableNameOverrides.put(reference, name);
+ }
-
- public String getLoggingEventExceptionColumnName(LoggingEventExceptionColumnName columnName) {
- if (leExceptionColumnNameOverrides.get(columnName) != null)
- return leExceptionColumnNameOverrides.get(columnName);
- return defaultDbNameResolver.getLoggingEventExceptionColumnName(columnName);
++ public void overrideColumnName(String reference, String name) {
++ columnNameOverrides.put(reference, name);
+ }
+
- public void setLoggingEventTableName(String tableName) {
- tableNameOverrides.put(TableName.LOGGING_EVENT, tableName);
- }
+
- public void setLoggingEventPropertyTableName(String tableName) {
- tableNameOverrides.put(TableName.LOGGING_EVENT_PROPERTY, tableName);
- }
-
- public void setLoggingEventExceptionTableName(String tableName) {
- tableNameOverrides.put(TableName.LOGGING_EVENT_EXCEPTION, tableName);
- }
-
- public void setLoggingEventTimestmpColumnName(String columnName) {
- leColumnNameOverrides.put(LoggingEventColumnName.TIMESTMP, columnName);
- }
-
- public void setLoggingEventFormattedMessageColumnName(String columnName) {
- leColumnNameOverrides.put(LoggingEventColumnName.FORMATTED_MESSAGE, columnName);
- }
-
- public void setLoggingEventLoggerNameColumnName(String columnName) {
- leColumnNameOverrides.put(LoggingEventColumnName.LOGGER_NAME, columnName);
- }
-
- public void setLoggingEventLevelStringColumnName(String columnName) {
- leColumnNameOverrides.put(LoggingEventColumnName.LEVEL_STRING, columnName);
- }
-
- public void setLoggingEventThreadNameColumnName(String columnName) {
- leColumnNameOverrides.put(LoggingEventColumnName.THREAD_NAME, columnName);
- }
-
- public void setLoggingEventReferenceFlagColumnName(String columnName) {
- leColumnNameOverrides.put(LoggingEventColumnName.REFERENCE_FLAG, columnName);
- }
-
- public void setLoggingEventCallerFilenameColumnName(String columnName) {
- leColumnNameOverrides.put(LoggingEventColumnName.CALLER_FILENAME, columnName);
- }
-
- public void setLoggingEventCallerClassColumnName(String columnName) {
- leColumnNameOverrides.put(LoggingEventColumnName.CALLER_CLASS, columnName);
- }
-
- public void setLoggingEventCallerMethodColumnName(String columnName) {
- leColumnNameOverrides.put(LoggingEventColumnName.CALLER_METHOD, columnName);
- }
-
- public void setLoggingEventCallerLineColumnName(String columnName) {
- leColumnNameOverrides.put(LoggingEventColumnName.CALLER_LINE, columnName);
- }
-
- public void setLoggingEventPropertyEventIdColumnName(String columnName) {
- lePropertyColumnNameOverrides.put(LoggingEventPropertyColumnName.EVENT_ID, columnName);
- }
-
- public void setMappedKeyColumnName(String columnName) {
- lePropertyColumnNameOverrides.put(LoggingEventPropertyColumnName.MAPPED_KEY, columnName);
- }
-
- public void setMappedValueColumnName(String columnName) {
- lePropertyColumnNameOverrides.put(LoggingEventPropertyColumnName.MAPPED_VALUE, columnName);
- }
-
- public void setLoggingEventExceptionEventIdColumnName(String columnName) {
- leExceptionColumnNameOverrides.put(LoggingEventExceptionColumnName.EVENT_ID, columnName);
- }
-
- public void setLoggingEventExceptionIColumnName(String columnName) {
- leExceptionColumnNameOverrides.put(LoggingEventExceptionColumnName.I, columnName);
- }
-
- public void setLoggingEventExceptionTraceLineColumnName(String columnName) {
- leExceptionColumnNameOverrides.put(LoggingEventExceptionColumnName.TRACE_LINE, columnName);
- }
++
+
+ }
diff --cc logback-classic/src/main/java/ch/qos/logback/classic/db/names/DBNameResolver.java
index 0000000,2647b00..e715fb5
mode 000000,100644..100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DBNameResolver.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DBNameResolver.java
@@@ -1,0 -1,13 +1,20 @@@
++/**
++ * Logback: the reliable, generic, fast and flexible logging framework.
++ * Copyright (C) 1999-2010, QOS.ch. All rights reserved.
++ *
++ * This program and the accompanying materials are dual-licensed under either
++ * the terms of the Eclipse Public License v1.0 as published by the Eclipse
++ * Foundation
++ *
++ * or (per the licensee's choosing)
++ *
++ * under the terms of the GNU Lesser General Public License version 2.1 as
++ * published by the Free Software Foundation.
++ */
+ package ch.qos.logback.classic.db.names;
+
+ public interface DBNameResolver {
+
- String getTableName(TableName tableName);
-
- String getLoggingEventColumnName(LoggingEventColumnName columnName);
-
- String getLoggingEventPropertyColumnName(LoggingEventPropertyColumnName columnName);
-
- String getLoggingEventExceptionColumnName(LoggingEventExceptionColumnName columnName);
-
++ <N extends Enum<?>> String getTableName(N tableName);
++ <N extends Enum<?>> String getColumnName(N columnName);
+ }
diff --cc logback-classic/src/main/java/ch/qos/logback/classic/db/names/DefaultDBNameResolver.java
index 0000000,fbf17cb..db88a52
mode 000000,100644..100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DefaultDBNameResolver.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DefaultDBNameResolver.java
@@@ -1,0 -1,23 +1,30 @@@
++/**
++ * Logback: the reliable, generic, fast and flexible logging framework.
++ * Copyright (C) 1999-2010, QOS.ch. All rights reserved.
++ *
++ * This program and the accompanying materials are dual-licensed under either
++ * the terms of the Eclipse Public License v1.0 as published by the Eclipse
++ * Foundation
++ *
++ * or (per the licensee's choosing)
++ *
++ * under the terms of the GNU Lesser General Public License version 2.1 as
++ * published by the Free Software Foundation.
++ */
+ package ch.qos.logback.classic.db.names;
+
+ /**
+ * @author Tomasz Nurkiewicz
+ * @since 2010-03-16
+ */
+ public class DefaultDBNameResolver implements DBNameResolver {
- public String getTableName(TableName tableName) {
- return tableName.name().toLowerCase();
- }
+
- public String getLoggingEventColumnName(LoggingEventColumnName columnName) {
- return columnName.name().toLowerCase();
++ public <N extends Enum<?>> String getTableName(N tableName) {
++ return tableName.toString();
+ }
+
- public String getLoggingEventPropertyColumnName(LoggingEventPropertyColumnName columnName) {
- return columnName.name().toLowerCase();
++ public <N extends Enum<?>> String getColumnName(N columnName) {
++ return columnName.toString();
+ }
+
- public String getLoggingEventExceptionColumnName(LoggingEventExceptionColumnName columnName) {
- return columnName.name().toLowerCase();
- }
+ }
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=35a2ffe580a13ad82f6798edf396ef9d5138e65b
http://github.com/ceki/logback/commit/35a2ffe580a13ad82f6798edf396ef9d5138e65b
commit 35a2ffe580a13ad82f6798edf396ef9d5138e65b
Merge: 2ff886b fd195dc
Author: Tomasz Nurkiewicz <nurkiewicz at gmail.com>
Date: Wed Mar 17 00:04:16 2010 +0100
Merge branch 'master' of git://github.com/ceki/logback
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=2ff886bfdc0e731e8ed39e6da029c3c88d130b75
http://github.com/ceki/logback/commit/2ff886bfdc0e731e8ed39e6da029c3c88d130b75
commit 2ff886bfdc0e731e8ed39e6da029c3c88d130b75
Author: Tomasz Nurkiewicz <nurkiewicz at gmail.com>
Date: Tue Mar 16 23:54:25 2010 +0100
[LBCLASSIC-188] Make table and column names overridable
* default implementation
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/DBAppender.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/DBAppender.java
index c4ecaa8..e055c5b 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/db/DBAppender.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/DBAppender.java
@@ -22,6 +22,8 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import ch.qos.logback.classic.db.names.DBNameResolver;
+import ch.qos.logback.classic.db.names.DefaultDBNameResolver;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.StackTraceElementProxy;
import ch.qos.logback.core.db.DBAppenderBase;
@@ -38,27 +40,14 @@ import ch.qos.logback.core.db.DBAppenderBase;
* @author Sébastien Pennec
*/
public class DBAppender extends DBAppenderBase<ILoggingEvent> {
- protected final String insertPropertiesSQL = "INSERT INTO logging_event_property (event_id, mapped_key, mapped_value) VALUES (?, ?, ?)";
- protected final String insertExceptionSQL = "INSERT INTO logging_event_exception (event_id, i, trace_line) VALUES (?, ?, ?)";
- protected static final String insertSQL;
+ protected String insertPropertiesSQL;
+ protected String insertExceptionSQL;
+ protected String insertSQL;
protected static final Method GET_GENERATED_KEYS_METHOD;
+ private DBNameResolver dbNameResolver;
+
static {
- StringBuffer sql = new StringBuffer();
- sql.append("INSERT INTO logging_event (");
- sql.append("timestmp, ");
- sql.append("formatted_message, ");
- sql.append("logger_name, ");
- sql.append("level_string, ");
- sql.append("thread_name, ");
- sql.append("reference_flag, ");
- sql.append("caller_filename, ");
- sql.append("caller_class, ");
- sql.append("caller_method, ");
- sql.append("caller_line) ");
- sql.append(" VALUES (?, ?, ? ,?, ?, ?, ?, ?, ?,?)");
- insertSQL = sql.toString();
-
// PreparedStatement.getGeneratedKeys() method was added in JDK 1.4
Method getGeneratedKeysMethod;
try {
@@ -74,6 +63,20 @@ public class DBAppender extends DBAppenderBase<ILoggingEvent> {
public DBAppender() {
}
+ public void setDbNameResolver(DBNameResolver dbNameResolver) {
+ this.dbNameResolver = dbNameResolver;
+ }
+
+ @Override
+ public void start() {
+ if(dbNameResolver == null)
+ dbNameResolver = new DefaultDBNameResolver();
+ insertExceptionSQL = SQLBuilder.buildInsertExceptionSQL(dbNameResolver);
+ insertPropertiesSQL = SQLBuilder.buildInsertPropertiesSQL(dbNameResolver);
+ insertSQL = SQLBuilder.buildInsertSQL(dbNameResolver);
+ super.start();
+ }
+
@Override
protected void subAppend(Object eventObject, Connection connection,
PreparedStatement insertStatement) throws Throwable {
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/SQLBuilder.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/SQLBuilder.java
new file mode 100644
index 0000000..9c197a0
--- /dev/null
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/SQLBuilder.java
@@ -0,0 +1,47 @@
+package ch.qos.logback.classic.db;
+
+import ch.qos.logback.classic.db.names.*;
+
+/**
+ * @author Tomasz Nurkiewicz
+ * @since 2010-03-16
+ */
+public class SQLBuilder {
+
+ static String buildInsertPropertiesSQL(DBNameResolver dbNameResolver) {
+ StringBuilder sqlBuilder = new StringBuilder("INSERT INTO ");
+ sqlBuilder.append(dbNameResolver.getTableName(TableName.LOGGING_EVENT_PROPERTY)).append(" (");
+ sqlBuilder.append(dbNameResolver.getLoggingEventPropertyColumnName(LoggingEventPropertyColumnName.EVENT_ID)).append(",");
+ sqlBuilder.append(dbNameResolver.getLoggingEventPropertyColumnName(LoggingEventPropertyColumnName.MAPPED_KEY)).append(",");
+ sqlBuilder.append(dbNameResolver.getLoggingEventPropertyColumnName(LoggingEventPropertyColumnName.MAPPED_VALUE)).append(") ");
+ sqlBuilder.append("VALUES (?, ?, ?)");
+ return sqlBuilder.toString();
+ }
+
+ static String buildInsertExceptionSQL(DBNameResolver dbNameResolver) {
+ StringBuilder sqlBuilder = new StringBuilder("INSERT INTO ");
+ sqlBuilder.append(dbNameResolver.getTableName(TableName.LOGGING_EVENT_EXCEPTION)).append(" (");
+ sqlBuilder.append(dbNameResolver.getLoggingEventExceptionColumnName(LoggingEventExceptionColumnName.EVENT_ID)).append(",");
+ sqlBuilder.append(dbNameResolver.getLoggingEventExceptionColumnName(LoggingEventExceptionColumnName.I)).append(",");
+ sqlBuilder.append(dbNameResolver.getLoggingEventExceptionColumnName(LoggingEventExceptionColumnName.TRACE_LINE)).append(") ");
+ sqlBuilder.append("VALUES (?, ?, ?)");
+ return sqlBuilder.toString();
+ }
+
+ static String buildInsertSQL(DBNameResolver dbNameResolver) {
+ StringBuilder sqlBuilder = new StringBuilder("INSERT INTO ");
+ sqlBuilder.append(dbNameResolver.getTableName(TableName.LOGGING_EVENT)).append(" (");
+ sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.TIMESTMP)).append(", ");
+ sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.FORMATTED_MESSAGE)).append(", ");
+ sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.LOGGER_NAME)).append(", ");
+ sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.LEVEL_STRING)).append(", ");
+ sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.THREAD_NAME)).append(", ");
+ sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.REFERENCE_FLAG)).append(", ");
+ sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.CALLER_FILENAME)).append(", ");
+ sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.CALLER_CLASS)).append(", ");
+ sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.CALLER_METHOD)).append(", ");
+ sqlBuilder.append(dbNameResolver.getLoggingEventColumnName(LoggingEventColumnName.CALLER_LINE)).append(") ");
+ sqlBuilder.append(" VALUES (?, ?, ? ,?, ?, ?, ?, ?, ?, ?)");
+ return sqlBuilder.toString();
+ }
+}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/CustomDBNameResolver.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/CustomDBNameResolver.java
new file mode 100644
index 0000000..0880aa5
--- /dev/null
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/CustomDBNameResolver.java
@@ -0,0 +1,118 @@
+package ch.qos.logback.classic.db.names;
+
+import java.util.EnumMap;
+import java.util.Map;
+
+/**
+ * @author Tomasz Nurkiewicz
+ * @since 2010-03-16
+ */
+public class CustomDBNameResolver implements DBNameResolver {
+
+ private final DBNameResolver defaultDbNameResolver = new DefaultDBNameResolver();
+ private final Map<TableName, String> tableNameOverrides = new EnumMap<TableName, String>(TableName.class);
+ private final Map<LoggingEventColumnName, String> leColumnNameOverrides = new EnumMap<LoggingEventColumnName, String>(LoggingEventColumnName.class);
+ private final Map<LoggingEventPropertyColumnName, String> lePropertyColumnNameOverrides = new EnumMap<LoggingEventPropertyColumnName, String>(LoggingEventPropertyColumnName.class);
+ private final Map<LoggingEventExceptionColumnName, String> leExceptionColumnNameOverrides = new EnumMap<LoggingEventExceptionColumnName, String>(LoggingEventExceptionColumnName.class);
+
+ public String getTableName(TableName tableName) {
+ if (tableNameOverrides.get(tableName) != null)
+ return tableNameOverrides.get(tableName);
+ return defaultDbNameResolver.getTableName(tableName);
+ }
+
+ public String getLoggingEventColumnName(LoggingEventColumnName columnName) {
+ if (leColumnNameOverrides.get(columnName) != null)
+ return leColumnNameOverrides.get(columnName);
+ return defaultDbNameResolver.getLoggingEventColumnName(columnName);
+ }
+
+ public String getLoggingEventPropertyColumnName(LoggingEventPropertyColumnName columnName) {
+ if (lePropertyColumnNameOverrides.get(columnName) != null)
+ return lePropertyColumnNameOverrides.get(columnName);
+ return defaultDbNameResolver.getLoggingEventPropertyColumnName(columnName);
+ }
+
+ public String getLoggingEventExceptionColumnName(LoggingEventExceptionColumnName columnName) {
+ if (leExceptionColumnNameOverrides.get(columnName) != null)
+ return leExceptionColumnNameOverrides.get(columnName);
+ return defaultDbNameResolver.getLoggingEventExceptionColumnName(columnName);
+ }
+
+ public void setLoggingEventTableName(String tableName) {
+ tableNameOverrides.put(TableName.LOGGING_EVENT, tableName);
+ }
+
+ public void setLoggingEventPropertyTableName(String tableName) {
+ tableNameOverrides.put(TableName.LOGGING_EVENT_PROPERTY, tableName);
+ }
+
+ public void setLoggingEventExceptionTableName(String tableName) {
+ tableNameOverrides.put(TableName.LOGGING_EVENT_EXCEPTION, tableName);
+ }
+
+ public void setLoggingEventTimestmpColumnName(String columnName) {
+ leColumnNameOverrides.put(LoggingEventColumnName.TIMESTMP, columnName);
+ }
+
+ public void setLoggingEventFormattedMessageColumnName(String columnName) {
+ leColumnNameOverrides.put(LoggingEventColumnName.FORMATTED_MESSAGE, columnName);
+ }
+
+ public void setLoggingEventLoggerNameColumnName(String columnName) {
+ leColumnNameOverrides.put(LoggingEventColumnName.LOGGER_NAME, columnName);
+ }
+
+ public void setLoggingEventLevelStringColumnName(String columnName) {
+ leColumnNameOverrides.put(LoggingEventColumnName.LEVEL_STRING, columnName);
+ }
+
+ public void setLoggingEventThreadNameColumnName(String columnName) {
+ leColumnNameOverrides.put(LoggingEventColumnName.THREAD_NAME, columnName);
+ }
+
+ public void setLoggingEventReferenceFlagColumnName(String columnName) {
+ leColumnNameOverrides.put(LoggingEventColumnName.REFERENCE_FLAG, columnName);
+ }
+
+ public void setLoggingEventCallerFilenameColumnName(String columnName) {
+ leColumnNameOverrides.put(LoggingEventColumnName.CALLER_FILENAME, columnName);
+ }
+
+ public void setLoggingEventCallerClassColumnName(String columnName) {
+ leColumnNameOverrides.put(LoggingEventColumnName.CALLER_CLASS, columnName);
+ }
+
+ public void setLoggingEventCallerMethodColumnName(String columnName) {
+ leColumnNameOverrides.put(LoggingEventColumnName.CALLER_METHOD, columnName);
+ }
+
+ public void setLoggingEventCallerLineColumnName(String columnName) {
+ leColumnNameOverrides.put(LoggingEventColumnName.CALLER_LINE, columnName);
+ }
+
+ public void setLoggingEventPropertyEventIdColumnName(String columnName) {
+ lePropertyColumnNameOverrides.put(LoggingEventPropertyColumnName.EVENT_ID, columnName);
+ }
+
+ public void setMappedKeyColumnName(String columnName) {
+ lePropertyColumnNameOverrides.put(LoggingEventPropertyColumnName.MAPPED_KEY, columnName);
+ }
+
+ public void setMappedValueColumnName(String columnName) {
+ lePropertyColumnNameOverrides.put(LoggingEventPropertyColumnName.MAPPED_VALUE, columnName);
+ }
+
+ public void setLoggingEventExceptionEventIdColumnName(String columnName) {
+ leExceptionColumnNameOverrides.put(LoggingEventExceptionColumnName.EVENT_ID, columnName);
+ }
+
+ public void setLoggingEventExceptionIColumnName(String columnName) {
+ leExceptionColumnNameOverrides.put(LoggingEventExceptionColumnName.I, columnName);
+ }
+
+ public void setLoggingEventExceptionTraceLineColumnName(String columnName) {
+ leExceptionColumnNameOverrides.put(LoggingEventExceptionColumnName.TRACE_LINE, columnName);
+ }
+
+}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DBNameResolver.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DBNameResolver.java
new file mode 100644
index 0000000..2647b00
--- /dev/null
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DBNameResolver.java
@@ -0,0 +1,13 @@
+package ch.qos.logback.classic.db.names;
+
+public interface DBNameResolver {
+
+ String getTableName(TableName tableName);
+
+ String getLoggingEventColumnName(LoggingEventColumnName columnName);
+
+ String getLoggingEventPropertyColumnName(LoggingEventPropertyColumnName columnName);
+
+ String getLoggingEventExceptionColumnName(LoggingEventExceptionColumnName columnName);
+
+}
\ No newline at end of file
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DefaultDBNameResolver.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DefaultDBNameResolver.java
new file mode 100644
index 0000000..fbf17cb
--- /dev/null
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/DefaultDBNameResolver.java
@@ -0,0 +1,23 @@
+package ch.qos.logback.classic.db.names;
+
+/**
+ * @author Tomasz Nurkiewicz
+ * @since 2010-03-16
+ */
+public class DefaultDBNameResolver implements DBNameResolver {
+ public String getTableName(TableName tableName) {
+ return tableName.name().toLowerCase();
+ }
+
+ public String getLoggingEventColumnName(LoggingEventColumnName columnName) {
+ return columnName.name().toLowerCase();
+ }
+
+ public String getLoggingEventPropertyColumnName(LoggingEventPropertyColumnName columnName) {
+ return columnName.name().toLowerCase();
+ }
+
+ public String getLoggingEventExceptionColumnName(LoggingEventExceptionColumnName columnName) {
+ return columnName.name().toLowerCase();
+ }
+}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/LoggingEventColumnName.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/LoggingEventColumnName.java
new file mode 100644
index 0000000..bc25465
--- /dev/null
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/LoggingEventColumnName.java
@@ -0,0 +1,20 @@
+package ch.qos.logback.classic.db.names;
+
+/**
+ * @author Tomasz Nurkiewicz
+ * @since 2010-03-15
+ */
+public enum LoggingEventColumnName {
+
+ TIMESTMP,
+ FORMATTED_MESSAGE,
+ LOGGER_NAME,
+ LEVEL_STRING,
+ THREAD_NAME,
+ REFERENCE_FLAG,
+ CALLER_FILENAME,
+ CALLER_CLASS,
+ CALLER_METHOD,
+ CALLER_LINE
+
+}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/LoggingEventExceptionColumnName.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/LoggingEventExceptionColumnName.java
new file mode 100644
index 0000000..2e12f1c
--- /dev/null
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/LoggingEventExceptionColumnName.java
@@ -0,0 +1,13 @@
+package ch.qos.logback.classic.db.names;
+
+/**
+ * @author Tomasz Nurkiewicz
+ * @since 2010-03-15
+ */
+public enum LoggingEventExceptionColumnName {
+
+ EVENT_ID,
+ I,
+ TRACE_LINE
+
+}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/LoggingEventPropertyColumnName.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/LoggingEventPropertyColumnName.java
new file mode 100644
index 0000000..f123e2d
--- /dev/null
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/LoggingEventPropertyColumnName.java
@@ -0,0 +1,13 @@
+package ch.qos.logback.classic.db.names;
+
+/**
+ * @author Tomasz Nurkiewicz
+ * @since 2010-03-15
+ */
+public enum LoggingEventPropertyColumnName {
+
+ EVENT_ID,
+ MAPPED_KEY,
+ MAPPED_VALUE
+
+}
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/names/TableName.java b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/TableName.java
new file mode 100644
index 0000000..9995361
--- /dev/null
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/names/TableName.java
@@ -0,0 +1,13 @@
+package ch.qos.logback.classic.db.names;
+
+/**
+ * @author Tomasz Nurkiewicz
+ * @since 2010-03-15
+ */
+public enum TableName {
+
+ LOGGING_EVENT,
+ LOGGING_EVENT_PROPERTY,
+ LOGGING_EVENT_EXCEPTION
+
+}
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=ffeda045d43d98eeb6bb420e87df9e726b9d34f7
http://github.com/ceki/logback/commit/ffeda045d43d98eeb6bb420e87df9e726b9d34f7
commit ffeda045d43d98eeb6bb420e87df9e726b9d34f7
Author: Tomasz Nurkiewicz <nurkiewicz at gmail.com>
Date: Mon Mar 15 23:48:11 2010 +0100
Ignore IntelliJ IDEA files
diff --git a/.gitignore b/.gitignore
index 6b74944..7e52e85 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,6 @@
target
.classpath
.project
-*~
\ No newline at end of file
+.idea
+*~
+*.iml
\ No newline at end of file
-----------------------------------------------------------------------
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
More information about the logback-dev
mailing list