skates 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/skates/runner.rb CHANGED
@@ -11,17 +11,7 @@ module Skates
11
11
  config_file = File.open('config/config.yaml')
12
12
  Skates.config = YAML.load(config_file)[Skates.environment]
13
13
 
14
- # Add an outputter to the logger
15
- log_file = Log4r::RollingFileOutputter.new("#{Skates.environment}", :filename => "log/#{Skates.environment}.log", :trunc => false)
16
- case Skates.environment
17
- when "production"
18
- log_file.formatter = Log4r::PatternFormatter.new(:pattern => "%d (#{Process.pid}) [%l] :: %m", :date_pattern => "%d/%m %H:%M")
19
- when "development"
20
- log_file.formatter = Log4r::PatternFormatter.new(:pattern => "%d (#{Process.pid}) [%l] :: %m", :date_pattern => "%d/%m %H:%M")
21
- else
22
- log_file.formatter = Log4r::PatternFormatter.new(:pattern => "%d (#{Process.pid}) [%l] :: %m", :date_pattern => "%d/%m %H:%M")
23
- end
24
- Skates.logger.add(log_file)
14
+ Skates.reopen_logs
25
15
 
26
16
  # Requiring all models, stanza, controllers
27
17
  ['app/models/*.rb', 'app/stanzas/*.rb', 'app/controllers/*_controller.rb'].each do |dir|
data/lib/skates.rb CHANGED
@@ -80,11 +80,31 @@ module Skates
80
80
  # Returns a shared logger for this component.
81
81
  def self.logger
82
82
  unless self.class_variable_defined?("@@logger")
83
- @@logger = Log4r::Logger.new("Skates")
84
- @@logger.add(Log4r::Outputter.stdout) if Skates.environment == "development"
83
+ reopen_logs
85
84
  end
86
85
  @@logger
87
86
  end
87
+
88
+ ##
89
+ # Re-opens the logs
90
+ # In "development" environment, the log will be on stdout
91
+ def self.reopen_logs
92
+ # Open a new logger
93
+ logger = Log4r::Logger.new("Skates")
94
+ logger.add(Log4r::Outputter.stdout) if Skates.environment == "development"
95
+ log_file = Log4r::RollingFileOutputter.new("#{Skates.environment}", :filename => "log/#{Skates.environment}.log", :trunc => false)
96
+ case Skates.environment
97
+ when "production"
98
+ log_file.formatter = Log4r::PatternFormatter.new(:pattern => "%d (#{Process.pid}) [%l] :: %m", :date_pattern => "%d/%m %H:%M")
99
+ when "development"
100
+ log_file.formatter = Log4r::PatternFormatter.new(:pattern => "%d (#{Process.pid}) [%l] :: %m", :date_pattern => "%d/%m %H:%M")
101
+ else
102
+ log_file.formatter = Log4r::PatternFormatter.new(:pattern => "%d (#{Process.pid}) [%l] :: %m", :date_pattern => "%d/%m %H:%M")
103
+ end
104
+ logger.add(log_file)
105
+ # Set up the variable.
106
+ @@logger = logger
107
+ end
88
108
 
89
109
  ##
90
110
  # Set the configuration for this component.
@@ -17,9 +17,7 @@ describe Skates::Runner do
17
17
  end
18
18
 
19
19
  it "should add the environment log file as an outputter to skates's default log" do
20
- @logger = Log4r::RollingFileOutputter.new("#{Skates.environment}", :filename => "log/#{Skates.environment}.log", :trunc => false)
21
- Log4r::RollingFileOutputter.should_receive(:new).with("test", :filename => "log/test.log", :trunc => false).and_return(@logger)
22
- Skates.logger.should_receive(:add).with(@logger)
20
+ Skates.should_receive(:reopen_logs)
23
21
  Skates::Runner.prepare("test")
24
22
  end
25
23
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - julien Genestoux
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-04 00:00:00 -08:00
12
+ date: 2009-11-11 00:00:00 -08:00
13
13
  default_executable: skates
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency