Switches from slf4j-nop to log4j. Uses built in logstash log4j setup. Switches to jar-dependencies (vendor'ed) instead of version controlled jars. Update logstash-api to v2. Does not yet support multi_recieve

This commit is contained in:
Karl Southern
2016-05-13 22:12:57 +01:00
parent d056093ab8
commit df811f3d29
10 changed files with 58 additions and 24 deletions

View File

@@ -83,6 +83,7 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
def register
@logger.info("JDBC - Starting up")
LogStash::Logger.setup_log4j(@logger)
load_jar_files!
@exceptions_tracker = RingBuffer.new(@max_flush_exceptions)
@@ -250,10 +251,10 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
def add_statement_event_params(statement, event)
@statement[1..-1].each_with_index do |i, idx|
case event[i]
case event.get(i)
when Time
# See LogStash::Timestamp, below, for the why behind strftime.
statement.setString(idx + 1, event[i].strftime(STRFTIME_FMT))
statement.setString(idx + 1, event.get(i).strftime(STRFTIME_FMT))
when LogStash::Timestamp
# XXX: Using setString as opposed to setTimestamp, because setTimestamp
# doesn't behave correctly in some drivers (Known: sqlite)
@@ -262,19 +263,19 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
# choke on the 'T' in the string (Known: Derby).
#
# strftime appears to be the most reliable across drivers.
statement.setString(idx + 1, event[i].time.strftime(STRFTIME_FMT))
statement.setString(idx + 1, event.get(i).time.strftime(STRFTIME_FMT))
when Fixnum, Integer
statement.setInt(idx + 1, event[i])
statement.setInt(idx + 1, event.get(i))
when Float
statement.setFloat(idx + 1, event[i])
statement.setFloat(idx + 1, event.get(i))
when String
statement.setString(idx + 1, event[i])
statement.setString(idx + 1, event.get(i))
when true
statement.setBoolean(idx + 1, true)
when false
statement.setBoolean(idx + 1, false)
else
if event[i].nil? and i =~ /%\{/
if event.get(i).nil? and i =~ /%\{/
statement.setString(idx + 1, event.sprintf(i))
else
statement.setString(idx + 1, nil)