lib/log4r/outputter/sequeloutputter.rb in log4r-sequel-0.0.2 vs lib/log4r/outputter/sequeloutputter.rb in log4r-sequel-0.0.3
- old
+ new
@@ -1,22 +1,10 @@
require 'log4r'
require 'log4r/yamlconfigurator'
require 'sequel'
require 'yaml'
-class Log4r::Logger
-
- # no parameters, returns the first Log4r::Outputter::Sequel object
- def get_outputter
- self.outputters.each do |op|
- next unless op.is_a?(SequelOutputter)
- return op
- end
- end
-
-end
-
class SequelOutputter < Log4r::Outputter
KNOWN_ENGINES = [
:postgres,
:sqlite,
@@ -49,10 +37,12 @@
@map = config[:map]
@delimiter = config[:delimiter]
{
:delimiter => @delimiter,
+ :engine => @engine,
+ :formatter => config[:formatter], # feels a bit weird mixing instance variables and referencing the hash directly
:map => @map,
:table => @table,
}.each_pair do |key, value|
raise Log4r::ConfigError.new(sprintf('required key[%s] missing from configuration', key)) if value.nil?
end
@@ -106,9 +96,10 @@
@dbh[@table].insert(hash)
end
def initialize_db
map = @map # we're in a different class in the block below, can't access
+ # TODO would be better to check to see if the DB is good rather than just throw an exception here
@dbh.create_table? @table do
primary_key :id
map.values.each do |v|
String v.to_sym
end