logger in Rails fixed
This commit is contained in:
parent
553833ded9
commit
967ac14819
2 changed files with 12 additions and 7 deletions
|
@ -157,11 +157,17 @@ 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
|
||||||
|
initializer "active_record.logger" do
|
||||||
|
SmqlToAR.logger = ::Rails.logger
|
||||||
|
$stderr.puts( { self: self, logger: SmqlToAR.logger}.inspect)
|
||||||
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
require 'logger'
|
require 'logger'
|
||||||
Logger.new $stdout
|
@@logger = Logger.new $stdout
|
||||||
|
$stderr.puts( { logger: @@logger}.inspect)
|
||||||
end
|
end
|
||||||
|
|
||||||
class <<self
|
class <<self
|
||||||
|
|
|
@ -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(',')}"
|
||||||
|
|
Loading…
Reference in a new issue