gem_logger 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTIzNzQ0NzlhNDdlMjkzMDk5NDM1ZTBjZWU3NmYxN2ZmMzhmNWQ1OQ==
5
+ data.tar.gz: !binary |-
6
+ MmFkOTczODI3NGFjZTczNWEzOTk2OTU4N2Q4MWY2ZDdmYTgyYTBkMQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YmU1OWJkMTFmMTg5MWExNDYwMzJjOWQ2OWM4N2ViZTI1ZDU3ZDQyM2MzOTc4
10
+ ZDBlZGVjODBhMGIwNTk3MmM0NzFkNGNjMTZlNTcxMGJmMTBkZWU4MTI0ZjYy
11
+ OTE1NDBlYzRiNjZhYmJiZWU2MDA0MmYxY2U2OGVjZjgwZjU1MzA=
12
+ data.tar.gz: !binary |-
13
+ MzYzZmMxYzAzYTZjOTRmNjUyOWI4YWY5NGRjYjZiNDhiNzM2OTdhMDAwNzdk
14
+ NzI4ZDhkZGY5OTBhZWY2MDI4ZjdlY2E2MzNiNzNlYzFhYzc0ZjljM2YxZGIx
15
+ NWEzODBlZDcxY2FkMTQ5MzQxNTlhNjdlYjc4Njc1NTI1ODMwMGY=
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - jruby-19mode
6
+ - rbx-19mode
7
+
8
+ script: bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gem_logger.gemspec
4
+ gemspec
5
+
6
+ # so we can test GemLogger.logger_concern
7
+ gem "lumber", :require => false
8
+
9
+ # for code coverage during travis-ci test runs
10
+ gem 'coveralls', :require => false
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Matt Conway
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ [![Build Status](https://secure.travis-ci.org/wr0ngway/gem_logger.png)](http://travis-ci.org/wr0ngway/gem_logger)
2
+ [![Coverage Status](https://coveralls.io/repos/wr0ngway/gem_logger/badge.png?branch=master)](https://coveralls.io/r/wr0ngway/gem_logger?branch=master)
3
+
4
+ # GemLogger
5
+
6
+ Allows classes/modules in gems to have logger class/instance methods with a pluggable Logger implementation
7
+
8
+ ## Usage
9
+
10
+ Include the GemLogger::Logger concern into the classes that need to be able to log. By default, it will use the standard Ruby logger, if you need a different logger, then configure GemLogger like:
11
+
12
+ GemLogger.configure do |config|
13
+
14
+ # The default logger instance to use
15
+ # (optional, defaults to Logger.new)
16
+ config.default_logger = CustomLogger.new
17
+
18
+ # module to include when GemLogger::Logger is included
19
+ # (optional, defaults to GemLogger::BasicLogger)
20
+ config.logger_concern = SomeModule
21
+
22
+ end
23
+
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.pattern = 'test/**/*_test.rb'
7
+ t.libs.push 'test'
8
+ end
9
+
10
+ task :default => :test
11
+
12
+ task :console do
13
+ Bundler.require
14
+ require "gem_logger"
15
+ ARGV.clear
16
+ require "irb"
17
+ IRB.start
18
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gem_logger/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gem_logger"
8
+ spec.version = GemLogger::VERSION
9
+ spec.authors = ["Matt Conway"]
10
+ spec.email = ["matt@conwaysplace.com"]
11
+ spec.description = %q{Allows classes/modules in gems to have logger class/instance methods with a pluggable Logger implementation}
12
+ spec.summary = %q{Allows classes/modules in gems to have logger class/instance methods with a pluggable Logger implementation}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "minitest"
24
+ spec.add_development_dependency "minitest_should"
25
+ spec.add_development_dependency "minitest-reporters"
26
+ spec.add_development_dependency "factory_girl"
27
+ spec.add_development_dependency "faker"
28
+
29
+ spec.add_dependency "activesupport"
30
+ end
@@ -0,0 +1,16 @@
1
+ module GemLogger
2
+
3
+ # Default support for built in ruby logger
4
+ module BasicLogger
5
+
6
+ extend ActiveSupport::Concern
7
+
8
+ module ClassMethods
9
+ def logger
10
+ GemLogger::default_logger
11
+ end
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,51 @@
1
+ module GemLogger
2
+ module LoggerSupport
3
+
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ # A guard to prevent misuse, may just want a log message instead of a hard fail
8
+ if self.class == Module && ! self.singleton_class.included_modules.include?(ActiveSupport::Concern)
9
+ raise ArgumentError, "module that includes #{self.name} must be an ActiveSupport::Concern"
10
+ end
11
+
12
+ include GemLogger.logger_concern
13
+
14
+ delegate :logger, :log_exception, :log_warning, :log_message, :to => "self.class"
15
+ end
16
+
17
+ module ClassMethods
18
+
19
+ def log_exception(exception, opts={})
20
+ logger.error("Exception #{generate_message(exception, opts)}")
21
+ end
22
+
23
+ def log_warning(exception, opts={})
24
+ logger.warn("Warning #{generate_message(exception, opts)}")
25
+ end
26
+
27
+ def log_message(group, message, opts={})
28
+ log_exception({:error_class => group,
29
+ :error_message => message },
30
+ opts)
31
+ end
32
+
33
+ def log_encode(str)
34
+ str.encode('UTF-8', :invalid => :replace, :undef => :replace, :replace => '')
35
+ end
36
+
37
+ def generate_message(exception, opts)
38
+ class_name = self.name
39
+ method_name = caller.first.gsub(/.*`(.*)'$/, '\1') rescue nil
40
+ opts = {:controller => class_name, :action => method_name}.merge(opts)
41
+
42
+ message_prefix = opts[:message_prefix] || ''
43
+ message_prefix += ' ' unless message_prefix.strip.size == 0
44
+
45
+ "#{log_encode(message_prefix)}#{log_encode(exception.inspect)}, #{log_encode(opts.inspect)}:\n#{exception.backtrace.collect {|x| log_encode(x)}.join("\n") rescue 'no backtrace'}"
46
+ end
47
+
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module GemLogger
2
+ VERSION = "0.1.0"
3
+ end
data/lib/gem_logger.rb ADDED
@@ -0,0 +1,52 @@
1
+ require "gem_logger/version"
2
+
3
+ require 'logger'
4
+ require 'active_support/concern'
5
+ require 'active_support/core_ext/module/delegation'
6
+
7
+ require "gem_logger/basic_logger"
8
+ require "gem_logger/logger_support"
9
+
10
+ # To configure gem_logger, add something like the
11
+ # following to an initializer (defaults shown):
12
+ #
13
+ # GemLogger.configure do |config|
14
+ #
15
+ # # The default logger instance to use
16
+ # # (optional, defaults to Logger.new)
17
+ # config.default_logger = CustomLogger.new
18
+ #
19
+ # # module to include when GemLogger::LoggerSupport is included
20
+ # # (optional, defaults to GemLogger::BasicLogger)
21
+ # config.logger_concern = SomeModule
22
+ #
23
+ # end
24
+ #
25
+ module GemLogger
26
+
27
+ # Allows configuring via class accessors
28
+ class << self
29
+ # The logger concern (ActiveSupport::Concern) to include when clients include GemLogger::Logger
30
+ # The module needs to cause a class level "logger" method (returning the logger instance) to be deSupportfined on the client
31
+ attr_accessor :logger_concern
32
+ end
33
+
34
+ # default values
35
+ self.logger_concern = GemLogger::BasicLogger
36
+
37
+ # The default_logger to use with GemLogger::BasicLogger
38
+ def self.default_logger
39
+ @default_logger ||= ::Logger.new(STDOUT)
40
+ end
41
+
42
+ # Set the default_logger to use with GemLogger::BasicLogger
43
+ def self.default_logger=(default_logger)
44
+ @default_logger = default_logger
45
+ end
46
+
47
+ # Allows configuring via class accessors
48
+ def self.configure
49
+ yield self
50
+ end
51
+
52
+ end
@@ -0,0 +1,72 @@
1
+ require 'rubygems'
2
+
3
+ if ENV['CI']
4
+ require 'coveralls'
5
+ Coveralls.wear!
6
+ end
7
+
8
+ require 'bundler'
9
+ begin
10
+ Bundler.setup(:default, :development)
11
+ rescue Bundler::BundlerError => e
12
+ $stderr.puts e.message
13
+ $stderr.puts "Run `bundle install` to install missing gems"
14
+ exit e.status_code
15
+ end
16
+
17
+ require 'minitest/autorun'
18
+ require 'minitest/should'
19
+ require "minitest/reporters"
20
+
21
+ reporter = ENV['REPORTER']
22
+ reporter = case reporter
23
+ when 'none' then nil
24
+ when 'spec' then MiniTest::Reporters::SpecReporter.new
25
+ when 'progress' then MiniTest::Reporters::ProgressReporter.new
26
+ else MiniTest::Reporters::DefaultReporter.new
27
+ end
28
+ MiniTest::Reporters.use!(reporter) if reporter
29
+
30
+ require 'gem_logger'
31
+
32
+ # Allow triggering single tests when running from rubymine
33
+ # reopen the installed runner so we don't step on runner customizations
34
+ class << MiniTest::Unit.runner
35
+ # Rubymine sends --name=/\Atest\: <context> should <should>\./
36
+ # Minitest runs each context as a suite
37
+ # Minitest filters methods by matching against: <suite>#test_0001_<should>
38
+ # Nested contexts are separted by spaces in rubymine, but ::s in minitest
39
+
40
+ def _run_suites(suites, type)
41
+ if options[:filter]
42
+ if options[:filter] =~ /\/\\Atest\\: (.*) should (.*)\\\.\//
43
+ context_filter = $1
44
+ should_filter = $2
45
+ should_filter.strip!
46
+ should_filter.gsub!(" ", "_")
47
+ should_filter.gsub!(/\W/, "")
48
+ context_filter = context_filter.gsub(" ", "((::)| )")
49
+ options[:filter] = "/\\A#{context_filter}(Test)?#test(_\\d+)?_should_#{should_filter}\\Z/"
50
+ end
51
+ end
52
+
53
+ super
54
+ end
55
+
56
+ # Prevent "Empty test suite" verbosity when running in rubymine
57
+ def _run_suite(suite, type)
58
+
59
+ filter = options[:filter] || '/./'
60
+ filter = Regexp.new $1 if filter =~ /\/(.*)\//
61
+ all_test_methods = suite.send "#{type}_methods"
62
+ filtered_test_methods = all_test_methods.find_all { |m|
63
+ filter === m || filter === "#{suite}##{m}"
64
+ }
65
+
66
+ if filtered_test_methods.size > 0
67
+ super
68
+ else
69
+ [0, 0]
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,18 @@
1
+ require_relative '../../test_helper'
2
+
3
+ module GemLogger
4
+ class BasicLoggerTest < Minitest::Should::TestCase
5
+
6
+ context "BasicLogger" do
7
+
8
+ should "define a logger class method" do
9
+ class MyClass
10
+ include GemLogger::BasicLogger
11
+ end
12
+ assert MyClass.respond_to?(:logger)
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,192 @@
1
+ require_relative '../../test_helper'
2
+
3
+ module GemLogger
4
+ class LoggerSupportTest < Minitest::Should::TestCase
5
+
6
+ setup do
7
+ @uniq = SecureRandom.uuid.gsub("-", "")
8
+ end
9
+
10
+ teardown do
11
+ LoggerSupportTest.constants.grep(/^Foo/).each do |c|
12
+ LoggerSupportTest.send(:remove_const, c)
13
+ end
14
+ end
15
+
16
+ def new_module(module_name, &block)
17
+ mod = self.class.const_set module_name, Module.new
18
+ mod.class_eval(&block)
19
+ mod
20
+ end
21
+
22
+ # can't do this dynamically as the class name needs to be set at inheritance time for lumber to work
23
+ def new_class(class_name, super_class=nil, &block)
24
+ s = "class #{class_name}"
25
+ s << " < #{super_class}" if super_class
26
+ s << "; end"
27
+
28
+ eval(s)
29
+ clazz = self.class.const_get(class_name)
30
+ clazz.class_eval(&block)
31
+ clazz
32
+ end
33
+
34
+ context "BasicLogger" do
35
+
36
+ setup do
37
+ @old_default_logger = GemLogger.default_logger
38
+ GemLogger.default_logger = Minitest::Mock.new
39
+ end
40
+
41
+ teardown do
42
+ GemLogger.default_logger.verify
43
+ GemLogger.default_logger = @old_default_logger
44
+ end
45
+
46
+ should "have a logger instance accessible from an instance method" do
47
+ foo = new_class("Foo#{@uniq}") { include GemLogger::LoggerSupport; def member_method; logger.debug('hi'); end; }
48
+ assert foo.new.respond_to?(:logger)
49
+ foo.logger.expect(:debug, nil, ['hi'])
50
+ foo.new.member_method
51
+ end
52
+
53
+ should "have a logger instance accessible from a class method " do
54
+ foo = new_class("Foo#{@uniq}") { include GemLogger::LoggerSupport; def self.class_method; logger.debug('hi'); end; }
55
+ assert foo.respond_to?(:logger)
56
+ foo.logger.expect(:debug, nil, ['hi'])
57
+ foo.class_method
58
+ end
59
+
60
+ should "have a logger instance when in a nested module" do
61
+ foomod = new_module("FooMod#{@uniq}") { extend ActiveSupport::Concern; include GemLogger::LoggerSupport; }
62
+ foo = new_class("Foo#{@uniq}") { include foomod; def member_method; logger.debug('hi'); end; }
63
+ assert foo.new.respond_to?(:logger)
64
+ foo.logger.expect(:debug, nil, ['hi'])
65
+ foo.new.member_method
66
+ end
67
+
68
+ should "fail when included in a module that is not a Concern" do
69
+ assert_raises(ArgumentError) do
70
+ new_module("FooMod#{@uniq}") { include GemLogger::LoggerSupport; }
71
+ end
72
+ end
73
+
74
+ should "have a log_exception method accessible from an instance method" do
75
+ foo = new_class("Foo#{@uniq}") { include GemLogger::LoggerSupport; def member_method; log_exception(RuntimeError.new("hell")); end; }
76
+ assert foo.new.respond_to?(:log_exception)
77
+ foo.logger.expect(:error, nil, [/.*/])
78
+ foo.new.member_method
79
+ end
80
+
81
+ should "have a log_exception method accessible from a class method " do
82
+ foo = new_class("Foo#{@uniq}") { include GemLogger::LoggerSupport; def self.class_method; log_exception(RuntimeError.new("hell")); end; }
83
+ assert foo.respond_to?(:log_exception)
84
+ foo.logger.expect(:error, nil, [/.*/])
85
+ foo.class_method
86
+ end
87
+
88
+ should "log_exception should populate class name as controller and method name as action" do
89
+ foo = new_class("Foo#{@uniq}") { include GemLogger::LoggerSupport; def self.class_method; log_exception(RuntimeError.new("hell")); end; }
90
+ foo.logger.expect(:error, nil, [/.*/])
91
+ foo.class_method
92
+ end
93
+
94
+ should "not raise exception on bad encoding" do
95
+ foo = new_class("Foo#{@uniq}") { include GemLogger::LoggerSupport; def self.class_method; log_exception(RuntimeError.new("\xE2".force_encoding('ASCII-8BIT'))); end; }
96
+ foo.logger.expect(:error, nil, [/.*/])
97
+ foo.class_method
98
+ end
99
+
100
+ context 'Generate Message' do
101
+ should 'properly generate messages with a message prefix' do
102
+ foo = new_class("Foo#{@uniq}") { include GemLogger::LoggerSupport; }
103
+ assert_match /^prefix /, foo.generate_message(StandardError.new('Hello'), {:message_prefix => 'prefix'})
104
+ end
105
+
106
+ should 'properly generate messages with a blank message prefix' do
107
+ foo = new_class("Foo#{@uniq}") { include GemLogger::LoggerSupport; }
108
+ assert_match /^#<StandardError: Hello>/, foo.generate_message(StandardError.new('Hello'), {:message_prefix => ''})
109
+ end
110
+
111
+ should 'properly generate messages with no message prefix' do
112
+ foo = new_class("Foo#{@uniq}") { include GemLogger::LoggerSupport; }
113
+ assert_match /^#<StandardError: Hello>/, foo.generate_message(StandardError.new('Hello'), {})
114
+ end
115
+ end
116
+
117
+ end
118
+
119
+ context "lumber integration" do
120
+
121
+ setup do
122
+ require 'lumber'
123
+
124
+ yml = <<-EOF
125
+ log4r_config:
126
+ pre_config:
127
+ root:
128
+ level: 'DEBUG'
129
+ loggers:
130
+ - name: "rails"
131
+ level: DEBUG
132
+ outputters: []
133
+ EOF
134
+
135
+ cfg = Log4r::YamlConfigurator
136
+ cfg.load_yaml_string(yml)
137
+ logger = Log4r::Logger['rails']
138
+ sio = StringIO.new
139
+ logger.outputters = [Log4r::IOOutputter.new("sbout", sio)]
140
+
141
+ Log4r::YamlConfigurator.stub(:load_yaml_file, nil) do
142
+ root = File.expand_path("../../..", __FILE__)
143
+ Lumber.init(:root => root, :env => 'test', :config_file => __FILE__)
144
+ end
145
+
146
+ @old_logger_concern = GemLogger.logger_concern
147
+ GemLogger.logger_concern = Lumber::LoggerSupport
148
+ end
149
+
150
+ teardown do
151
+ GemLogger.logger_concern = @old_logger_concern
152
+ end
153
+
154
+ should "have a logger instance accessible from an instance method" do
155
+ foo = new_class("Foo#{@uniq}") { include GemLogger::LoggerSupport; }
156
+ assert_equal "rails::GemLogger::LoggerSupportTest::#{foo.name.split('::').last}", foo.new.logger.fullname
157
+ end
158
+
159
+ should "have a logger instance accessible from a class method " do
160
+ foo = new_class("Foo#{@uniq}") { include GemLogger::LoggerSupport; }
161
+ assert_equal "rails::GemLogger::LoggerSupportTest::#{foo.name.split('::').last}", foo.logger.fullname
162
+ end
163
+
164
+ should "have a logger instance when in a nested module" do
165
+ foomod = new_module("FooMod#{@uniq}") { extend ActiveSupport::Concern; include GemLogger::LoggerSupport; }
166
+ foo = new_class("Foo#{@uniq}") { include foomod; }
167
+ assert_equal "rails::GemLogger::LoggerSupportTest::#{foo.name.split('::').last}", foo.logger.fullname
168
+ end
169
+
170
+ should "have correct logger instance with multiple includes" do
171
+ foomod = new_module("FooMod#{@uniq}") { extend ActiveSupport::Concern; include GemLogger::LoggerSupport; }
172
+ foo = new_class("Foo#{@uniq}") { include GemLogger::LoggerSupport; include foomod; }
173
+ assert_equal "rails::GemLogger::LoggerSupportTest::#{foo.name.split('::').last}", foo.logger.fullname
174
+ end
175
+
176
+ should "have correct logger instance with includes and inheritance" do
177
+ foosuper = new_class("FooSuper#{@uniq}") { include GemLogger::LoggerSupport; }
178
+ foo = new_class("Foo#{@uniq}", foosuper) { }
179
+ assert_equal "rails::GemLogger::LoggerSupportTest::#{foosuper.name.split('::').last}::#{foo.name.split('::').last}", foo.logger.fullname
180
+ end
181
+
182
+ should "have correct logger instance with multiple includes and inheritance" do
183
+ foomod = new_module("FooMod#{@uniq}") { extend ActiveSupport::Concern; include GemLogger::LoggerSupport; }
184
+ foosuper = new_class("FooSuper#{@uniq}") { include foomod; }
185
+ foo = new_class("Foo#{@uniq}", foosuper) { include GemLogger::LoggerSupport; include foomod; }
186
+ assert_equal "rails::GemLogger::LoggerSupportTest::#{foosuper.name.split('::').last}::#{foo.name.split('::').last}", foo.logger.fullname
187
+ end
188
+
189
+ end
190
+
191
+ end
192
+ end
@@ -0,0 +1,38 @@
1
+ require_relative '../test_helper'
2
+
3
+ class GemLoggerTest < MiniTest::Should::TestCase
4
+
5
+ context "configure" do
6
+
7
+ should "provide a default value for default_logger" do
8
+ GemLogger.default_logger = nil
9
+ assert_instance_of Logger, GemLogger.default_logger
10
+ end
11
+
12
+ should "provide a default value for logger_concern" do
13
+ assert_equal GemLogger::BasicLogger, GemLogger.logger_concern
14
+ end
15
+
16
+ should "allow config through #configure" do
17
+ old_logger = GemLogger.default_logger
18
+ old_concern = GemLogger.logger_concern
19
+
20
+ begin
21
+ logger = Logger.new(STDOUT)
22
+ concern = Module.new { FOO = 'bar' }
23
+ GemLogger.configure do |config|
24
+ config.default_logger = logger
25
+ config.logger_concern = concern
26
+ end
27
+
28
+ assert_equal logger, GemLogger.default_logger
29
+ assert_equal concern, GemLogger.logger_concern
30
+ ensure
31
+ GemLogger.default_logger = old_logger
32
+ GemLogger.logger_concern = old_concern
33
+ end
34
+ end
35
+
36
+ end
37
+
38
+ end
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem_logger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Matt Conway
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ prerelease: false
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.3'
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ~>
24
+ - !ruby/object:Gem::Version
25
+ version: '1.3'
26
+ type: :development
27
+ - !ruby/object:Gem::Dependency
28
+ prerelease: false
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: !binary |-
35
+ MA==
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: !binary |-
41
+ MA==
42
+ type: :development
43
+ - !ruby/object:Gem::Dependency
44
+ prerelease: false
45
+ name: minitest
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: !binary |-
51
+ MA==
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: !binary |-
57
+ MA==
58
+ type: :development
59
+ - !ruby/object:Gem::Dependency
60
+ prerelease: false
61
+ name: minitest_should
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: !binary |-
67
+ MA==
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: !binary |-
73
+ MA==
74
+ type: :development
75
+ - !ruby/object:Gem::Dependency
76
+ prerelease: false
77
+ name: minitest-reporters
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: !binary |-
83
+ MA==
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: !binary |-
89
+ MA==
90
+ type: :development
91
+ - !ruby/object:Gem::Dependency
92
+ prerelease: false
93
+ name: factory_girl
94
+ requirement: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: !binary |-
99
+ MA==
100
+ version_requirements: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: !binary |-
105
+ MA==
106
+ type: :development
107
+ - !ruby/object:Gem::Dependency
108
+ prerelease: false
109
+ name: faker
110
+ requirement: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: !binary |-
115
+ MA==
116
+ version_requirements: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: !binary |-
121
+ MA==
122
+ type: :development
123
+ - !ruby/object:Gem::Dependency
124
+ prerelease: false
125
+ name: activesupport
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: !binary |-
131
+ MA==
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: !binary |-
137
+ MA==
138
+ type: :runtime
139
+ description: Allows classes/modules in gems to have logger class/instance methods
140
+ with a pluggable Logger implementation
141
+ email:
142
+ - matt@conwaysplace.com
143
+ executables: []
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - .coveralls.yml
148
+ - .gitignore
149
+ - .travis.yml
150
+ - Gemfile
151
+ - LICENSE.txt
152
+ - README.md
153
+ - Rakefile
154
+ - gem_logger.gemspec
155
+ - lib/gem_logger.rb
156
+ - lib/gem_logger/basic_logger.rb
157
+ - lib/gem_logger/logger_support.rb
158
+ - lib/gem_logger/version.rb
159
+ - test/test_helper.rb
160
+ - test/unit/gem_logger/basic_logger_test.rb
161
+ - test/unit/gem_logger/logger_support_test.rb
162
+ - test/unit/gem_logger_test.rb
163
+ homepage: ''
164
+ licenses:
165
+ - MIT
166
+ metadata: {}
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: !binary |-
176
+ MA==
177
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: !binary |-
182
+ MA==
183
+ requirements: []
184
+ rubyforge_project:
185
+ rubygems_version: 2.0.6
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: Allows classes/modules in gems to have logger class/instance methods with
189
+ a pluggable Logger implementation
190
+ test_files:
191
+ - test/test_helper.rb
192
+ - test/unit/gem_logger/basic_logger_test.rb
193
+ - test/unit/gem_logger/logger_support_test.rb
194
+ - test/unit/gem_logger_test.rb