Permalink
Browse files

Remove logger method that was getting mixed in everywhere....

  - bad idea and too dangerous
  - move version to Version class
  • Loading branch information...
1 parent b142683 commit 4df75cb969c2a519285c0f0fa26909c00a4c5c8c @rsanheim rsanheim committed May 26, 2010
Showing with 25 additions and 35 deletions.
  1. +4 −1 CHANGELOG
  2. +10 −2 Rakefile
  3. +0 −4 lib/log_buddy/mixin.rb
  4. +2 −2 lib/log_buddy/version.rb
  5. +8 −14 spec/log_buddy/log_buddy_spec.rb
  6. +1 −12 spec/log_buddy/log_spec.rb
View
@@ -1,4 +1,7 @@
-v0.x.x. Cleanup: move to Rspec; remove GemLoger
+v0.x.x. Overall cleanup and making things safer:
+ - move to Rspec
+ - remove GemLoger
+ - don't mixin in a logger method to Object, ever -- too dangerous.
v0.4.10 Switch to jeweler; remove dependencies that were superfluous
View
@@ -1,7 +1,11 @@
+$:.unshift File.expand_path('../lib', __FILE__)
+
begin
require 'jeweler'
+ require 'log_buddy/version'
Jeweler::Tasks.new do |gem|
gem.name = "log_buddy"
+ gem.version = LogBuddy::Version::STRING
gem.summary = %Q{Log Buddy is your little development buddy.}
gem.description = %Q{Log statements along with their name easily. Mixin a logger everywhere when you need it.}
gem.email = "rsanheim@gmail.com"
@@ -26,7 +30,11 @@ begin
spec.rcov = true
end
- task :default => [:check_dependencies, :coverage]
+ if RUBY_VERSION <= "1.8.7"
+ task :default => [:check_dependencies, :coverage]
+ else
+ task :default => [:check_dependencies, :spec]
+ end
rescue LoadError => e
puts "Rspec not available to run tests. Install it with: gem install rspec --pre"
puts e
@@ -43,7 +51,7 @@ end
require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
- version = File.exist?('VERSION') ? File.read('VERSION') : ''
+ version = LogBuddy::Version::STRING
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "log_buddy #{version}"
rdoc.rdoc_files.include('README*')
@@ -23,9 +23,5 @@ def d(msg = nil, &blk)
LogBuddy.debug "LogBuddy caught an exception: #{e.message}"
end
end
-
- def logger
- LogBuddy.logger
- end
end
end
@@ -1,8 +1,8 @@
module LogBuddy
- module VERSION #:nodoc:
+ module Version #:nodoc:
MAJOR = 0
MINOR = 4
- TINY = 9
+ TINY = 12
STRING = [MAJOR, MINOR, TINY].join('.')
end
@@ -9,20 +9,14 @@
it "has stdout config option" do
LogBuddy.should respond_to(:log_to_stdout?)
end
-
- describe "init" do
- it "mixes itself into Object instance and class level by default" do
- Object.expects(:include).with(LogBuddy::Mixin)
- Object.expects(:extend).with(LogBuddy::Mixin)
- LogBuddy.init
- end
- it "adds logger method to Object instance and class" do
- LogBuddy.init
- Object.new.should respond_to(:logger)
- Object.should respond_to(:logger)
- end
-
+ it "can override the default logger" do
+ file_logger = Logger.new "test.log"
+ LogBuddy.init :logger => file_logger
+ LogBuddy.logger.should == file_logger
+ end
+
+ describe "init" do
it "defaults to log to stdout (as well as logger)" do
LogBuddy.init
LogBuddy.log_to_stdout?.should == true
@@ -33,5 +27,5 @@
LogBuddy.log_to_stdout?.should == true
end
end
-
+
end
@@ -20,23 +20,12 @@ def self.raise_runtime_error
begin
Object.const_set "RAILS_DEFAULT_LOGGER", stub_everything
LogBuddy.init
- Object.logger.should == RAILS_DEFAULT_LOGGER
+ LogBuddy.logger.should == RAILS_DEFAULT_LOGGER
ensure
Object.send :remove_const, "RAILS_DEFAULT_LOGGER"
end
end
- it "uses a plain STDOUT Ruby logger if there is no RAILS_DEFAULT_LOGGER" do
- LogBuddy.init
- Object.logger.should == LogBuddy.logger
- end
-
- it "can override the default logger" do
- file_logger = Logger.new "test.log"
- LogBuddy.init :logger => file_logger
- Object.logger.should == file_logger
- end
-
describe "outputting the code being logged and its result" do
before { LogBuddy.init :log_to_stdout => false }
it "should log to default logger" do

0 comments on commit 4df75cb

Please sign in to comment.