Commit 569c23798c73a68a89c81fdd01cdffc8f7c4ac16

Authored by Rodrigo Souto
1 parent 1aeb0d56

[spaminator] Moving spaminator lot to noosfero default log file

plugins/spaminator/lib/spaminator_plugin/spaminator.rb
@@ -12,7 +12,10 @@ class SpaminatorPlugin::Spaminator @@ -12,7 +12,10 @@ class SpaminatorPlugin::Spaminator
12 puts Benchmark.measure { run(environment) } 12 puts Benchmark.measure { run(environment) }
13 end 13 end
14 14
15 - def initialize_logger(logpath) 15 + def initialize_logger(environment)
  16 + logdir = File.join(RAILS_ROOT, 'log', SpaminatorPlugin.name.underscore)
  17 + File.makedirs(logdir) if !File.exist?(logdir)
  18 + logpath = File.join(logdir, "#{environment.name.to_slug}_#{ENV['RAILS_ENV']}_#{Time.now.strftime("%F_%T")}.log")
16 @logger = Logger.new(logpath) 19 @logger = Logger.new(logpath)
17 end 20 end
18 21
@@ -28,8 +31,7 @@ class SpaminatorPlugin::Spaminator @@ -28,8 +31,7 @@ class SpaminatorPlugin::Spaminator
28 @report = SpaminatorPlugin::Report.new(:environment => environment, 31 @report = SpaminatorPlugin::Report.new(:environment => environment,
29 :total_people => Person.count, 32 :total_people => Person.count,
30 :total_comments => Comment.count) 33 :total_comments => Comment.count)
31 - logpath = File.join(SpaminatorPlugin.root_path, 'log', "#{environment.name.to_slug}_#{ENV['RAILS_ENV']}_#{Time.now.strftime("%F_%T")}.log")  
32 - self.class.initialize_logger(logpath) 34 + self.class.initialize_logger(environment)
33 end 35 end
34 36
35 def run 37 def run