logger in Rails fixed
This commit is contained in:
parent
553833ded9
commit
967ac14819
2 changed files with 12 additions and 7 deletions
|
@ -157,12 +157,18 @@ class SmqlToAR
|
|||
|
||||
attr_reader :model, :query, :conditions, :builder, :order
|
||||
attr_accessor :logger
|
||||
@@logger = if Object.const_defined?( :Rails)
|
||||
Rails.logger
|
||||
else
|
||||
require 'logger'
|
||||
Logger.new $stdout
|
||||
if defined? Rails
|
||||
class Railtie < ::Rails::Railtie
|
||||
initializer "active_record.logger" do
|
||||
SmqlToAR.logger = ::Rails.logger
|
||||
$stderr.puts( { self: self, logger: SmqlToAR.logger}.inspect)
|
||||
end
|
||||
end
|
||||
else
|
||||
require 'logger'
|
||||
@@logger = Logger.new $stdout
|
||||
$stderr.puts( { logger: @@logger}.inspect)
|
||||
end
|
||||
|
||||
class <<self
|
||||
def logger=(logger) @@logger = logger end
|
||||
|
|
|
@ -30,10 +30,9 @@ class SmqlToAR
|
|||
|
||||
attr_reader :table_alias, :model, :table_model, :base_table, :_where, :_select, :_wobs, :_joins
|
||||
attr_accessor :logger
|
||||
@@logger = SmqlToAR.logger
|
||||
|
||||
def initialize model
|
||||
@logger = @@logger
|
||||
@logger = SmqlToAR.logger
|
||||
@table_alias = Hash.new do |h, k|
|
||||
k = Array.wrap k
|
||||
h[k] = "smql,#{k.join(',')}"
|
||||
|
|
Loading…
Reference in a new issue