log_buddy 0.2.3 → 0.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v0.4.9 Added gem logging for debugging help when tracking down Gem activation errors
2
+
1
3
  v0.2.3 Updating Micronaut
2
4
 
3
5
  v0.2.0. Better log output of objects based on their type, very similar to Logger/irb behavior; update to micronaut 0.1.0
data/Manifest CHANGED
@@ -1,10 +1,12 @@
1
1
  CHANGELOG
2
- examples/example_helper.rb
3
- examples/log_buddy_example.rb
4
- examples/log_buddy_init_example.rb
5
- examples/log_example.rb
2
+ examples/log_buddy/example_helper.rb
3
+ examples/log_buddy/gem_logger_example.rb
4
+ examples/log_buddy/log_buddy_example.rb
5
+ examples/log_buddy/log_buddy_init_example.rb
6
+ examples/log_buddy/log_example.rb
6
7
  examples.rb
7
8
  init.rb
9
+ lib/log_buddy/gem_logger.rb
8
10
  lib/log_buddy/mixin.rb
9
11
  lib/log_buddy/utils.rb
10
12
  lib/log_buddy/version.rb
@@ -4,7 +4,7 @@ gem "spicycode-micronaut", ">= 0.2.0"
4
4
  gem 'mocha'
5
5
  require "mocha"
6
6
  require 'micronaut'
7
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "log_buddy"))
7
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "log_buddy"))
8
8
 
9
9
  def silence_warnings
10
10
  old_verbose, $VERBOSE = $VERBOSE, nil
@@ -16,5 +16,6 @@ end
16
16
  Micronaut.configure do |config|
17
17
  config.mock_with :mocha
18
18
  config.formatter = :documentation
19
+ config.color_enabled = true
19
20
  config.filter_run :options => { :focused => true }
20
21
  end
@@ -0,0 +1,45 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), *%w[example_helper]))
2
+
3
+ describe LogBuddy::GemLogger do
4
+
5
+ describe "starting Gem logging" do
6
+
7
+ it "includes GemLogger into Gem when #log_gems! is called" do
8
+ Gem.expects(:include).with(LogBuddy::GemLogger)
9
+ LogBuddy::GemLogger.log_gems!
10
+ end
11
+
12
+ end
13
+
14
+ describe "Gem#activation monkey patching for logging" do
15
+
16
+ before do
17
+ LogBuddy.init
18
+ LogBuddy::GemLogger.log_gems!
19
+ end
20
+
21
+ it "should log the gem name and version and where it was called from" do
22
+ Gem.stubs(:activate_without_logging)
23
+
24
+ LogBuddy.expects(:debug).with do |msg|
25
+ msg.should include(%[Gem activation for gem: 'gem-name' version: '0.5' called from:\n])
26
+ gem_calling_line = __LINE__ + 3
27
+ msg.should include(%[examples/log_buddy/gem_logger_example.rb:#{gem_calling_line}])
28
+ end
29
+ gem "gem-name", "0.5"
30
+ end
31
+
32
+ it "should do the original gem activation call" do
33
+ LogBuddy.stubs(:debug)
34
+ Gem.expects(:activate_without_logging).with('gem-name', ">= 1.0.0")
35
+ gem "gem-name", ">= 1.0.0"
36
+ end
37
+
38
+ it "should add alias gem_without_logging" do
39
+ Gem.should respond_to(:activate)
40
+ Gem.should respond_to(:activate_without_logging)
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -4,6 +4,11 @@ describe LogBuddy do
4
4
  describe "init" do
5
5
  after { reset_safe_log_buddy_mode }
6
6
 
7
+ it "should call log_gems! if log_gems is true" do
8
+ LogBuddy::GemLogger.expects(:log_gems!)
9
+ LogBuddy.init :log_gems => true
10
+ end
11
+
7
12
  it "doesnt mixin to object if SAFE_LOG_BUDDY is true" do
8
13
  LogBuddy.expects(:init).never
9
14
  ENV["SAFE_LOG_BUDDY"] = "true"
@@ -17,7 +22,7 @@ describe LogBuddy do
17
22
 
18
23
  def load_init
19
24
  silence_warnings do
20
- load File.join(File.dirname(__FILE__), *%w[.. init.rb])
25
+ load File.join(File.dirname(__FILE__), *%w[.. .. init.rb])
21
26
  end
22
27
  end
23
28
 
data/lib/log_buddy.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), *%w[log_buddy utils])
2
2
  require File.join(File.dirname(__FILE__), *%w[log_buddy mixin])
3
+ require File.join(File.dirname(__FILE__), *%w[log_buddy gem_logger])
3
4
  require File.join(File.dirname(__FILE__), *%w[log_buddy version])
4
5
 
5
6
  =begin rdoc
@@ -27,11 +28,14 @@ module LogBuddy
27
28
  # tries to default to RAILS_DEFAULT_LOGGER, and then to a STDOUT logger).
28
29
  # * <tt):log_to_stdout</tt> - whether LogBuddy should _also_ log to STDOUT, very helpful for Autotest (default is +true+).
29
30
  # * <tt>:disabled</tt> - when true, LogBuddy will not produce any output
31
+ # * <tt>:log_gems</tt> - log Gem activation process - useful for tracking down Gem activation errors (default is +false+)
30
32
  def self.init(options = {})
31
33
  @logger = options[:logger]
32
34
  @log_to_stdout = options.has_key?(:log_to_stdout) ? options[:log_to_stdout] : true
35
+ @log_gems = options[:log_gems]
33
36
  @disabled = (options[:disabled] == true)
34
37
  mixin_to_object
38
+ GemLogger.log_gems! if @log_gems
35
39
  end
36
40
 
37
41
  # Add the LogBuddy::Mixin to Object instance and class level.
@@ -0,0 +1,24 @@
1
+ module LogBuddy
2
+ module GemLogger
3
+
4
+ BACKTRACE_SIZE = 0..5
5
+
6
+ def self.log_gems!
7
+ Gem.send :include, LogBuddy::GemLogger
8
+ end
9
+
10
+ def self.included(mod)
11
+
12
+ class << mod
13
+ def activate_with_logging(gem, *version_requirements)
14
+ d %[Gem activation for gem: '#{gem}' version: '#{version_requirements}' called from:\n#{caller[BACKTRACE_SIZE].join("\n")}]
15
+ activate_without_logging(gem, *version_requirements)
16
+ end
17
+
18
+ alias_method :activate_without_logging, :activate
19
+ alias_method :activate, :activate_with_logging
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -1,8 +1,8 @@
1
1
  module LogBuddy
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 2
5
- TINY = 3
4
+ MINOR = 4
5
+ TINY = 9
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/log_buddy.gemspec CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{log_buddy}
5
- s.version = "0.2.3"
5
+ s.version = "0.4.9"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Rob Sanheim - Relevance"]
9
- s.date = %q{2009-01-17}
9
+ s.date = %q{2009-01-20}
10
10
  s.description = %q{Log statements along with their name easily. Mixin a logger everywhere when you need it.}
11
11
  s.email = %q{opensource@thinkrelevance.com}
12
- s.extra_rdoc_files = ["CHANGELOG", "lib/log_buddy/mixin.rb", "lib/log_buddy/utils.rb", "lib/log_buddy/version.rb", "lib/log_buddy.rb", "LICENSE", "log_buddy.gemspec", "README.rdoc"]
13
- s.files = ["CHANGELOG", "examples/example_helper.rb", "examples/log_buddy_example.rb", "examples/log_buddy_init_example.rb", "examples/log_example.rb", "examples.rb", "init.rb", "lib/log_buddy/mixin.rb", "lib/log_buddy/utils.rb", "lib/log_buddy/version.rb", "lib/log_buddy.rb", "LICENSE", "log_buddy.gemspec", "Manifest", "Rakefile", "README.rdoc"]
12
+ s.extra_rdoc_files = ["CHANGELOG", "lib/log_buddy/gem_logger.rb", "lib/log_buddy/mixin.rb", "lib/log_buddy/utils.rb", "lib/log_buddy/version.rb", "lib/log_buddy.rb", "LICENSE", "log_buddy.gemspec", "README.rdoc"]
13
+ s.files = ["CHANGELOG", "examples/log_buddy/example_helper.rb", "examples/log_buddy/gem_logger_example.rb", "examples/log_buddy/log_buddy_example.rb", "examples/log_buddy/log_buddy_init_example.rb", "examples/log_buddy/log_example.rb", "examples.rb", "init.rb", "lib/log_buddy/gem_logger.rb", "lib/log_buddy/mixin.rb", "lib/log_buddy/utils.rb", "lib/log_buddy/version.rb", "lib/log_buddy.rb", "LICENSE", "log_buddy.gemspec", "Manifest", "Rakefile", "README.rdoc"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://github.com/relevance/log_buddy}
16
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Log_buddy", "--main", "README.rdoc"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log_buddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Sanheim - Relevance
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-17 00:00:00 -05:00
12
+ date: 2009-01-20 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -70,6 +70,7 @@ extensions: []
70
70
 
71
71
  extra_rdoc_files:
72
72
  - CHANGELOG
73
+ - lib/log_buddy/gem_logger.rb
73
74
  - lib/log_buddy/mixin.rb
74
75
  - lib/log_buddy/utils.rb
75
76
  - lib/log_buddy/version.rb
@@ -79,12 +80,14 @@ extra_rdoc_files:
79
80
  - README.rdoc
80
81
  files:
81
82
  - CHANGELOG
82
- - examples/example_helper.rb
83
- - examples/log_buddy_example.rb
84
- - examples/log_buddy_init_example.rb
85
- - examples/log_example.rb
83
+ - examples/log_buddy/example_helper.rb
84
+ - examples/log_buddy/gem_logger_example.rb
85
+ - examples/log_buddy/log_buddy_example.rb
86
+ - examples/log_buddy/log_buddy_init_example.rb
87
+ - examples/log_buddy/log_example.rb
86
88
  - examples.rb
87
89
  - init.rb
90
+ - lib/log_buddy/gem_logger.rb
88
91
  - lib/log_buddy/mixin.rb
89
92
  - lib/log_buddy/utils.rb
90
93
  - lib/log_buddy/version.rb