logger in Rails fixed

This commit is contained in:
Denis Knauf 2011-09-11 12:39:13 +02:00
parent 553833ded9
commit 967ac14819
2 changed files with 12 additions and 7 deletions

View file

@ -157,12 +157,18 @@ class SmqlToAR
attr_reader :model, :query, :conditions, :builder, :order attr_reader :model, :query, :conditions, :builder, :order
attr_accessor :logger attr_accessor :logger
@@logger = if Object.const_defined?( :Rails) if defined? Rails
Rails.logger class Railtie < ::Rails::Railtie
else initializer "active_record.logger" do
require 'logger' SmqlToAR.logger = ::Rails.logger
Logger.new $stdout $stderr.puts( { self: self, logger: SmqlToAR.logger}.inspect)
end
end end
else
require 'logger'
@@logger = Logger.new $stdout
$stderr.puts( { logger: @@logger}.inspect)
end
class <<self class <<self
def logger=(logger) @@logger = logger end def logger=(logger) @@logger = logger end

View file

@ -30,10 +30,9 @@ class SmqlToAR
attr_reader :table_alias, :model, :table_model, :base_table, :_where, :_select, :_wobs, :_joins attr_reader :table_alias, :model, :table_model, :base_table, :_where, :_select, :_wobs, :_joins
attr_accessor :logger attr_accessor :logger
@@logger = SmqlToAR.logger
def initialize model def initialize model
@logger = @@logger @logger = SmqlToAR.logger
@table_alias = Hash.new do |h, k| @table_alias = Hash.new do |h, k|
k = Array.wrap k k = Array.wrap k
h[k] = "smql,#{k.join(',')}" h[k] = "smql,#{k.join(',')}"