easy_log4r 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Add dependencies required to use your gem here.
4
+ # Example:
5
+ # gem "activesupport", ">= 2.3.5"
6
+
7
+ gem "log4r", ">= 0"
8
+
9
+ # Add dependencies to develop your gem here.
10
+ # Include everything needed to run rake, tests, features, etc.
11
+ group :development do
12
+ gem "shoulda", ">= 0"
13
+ gem "shoulda-context", ">= 0"
14
+ gem "rdoc", "~> 3.12"
15
+ gem "jeweler", "~> 1.8.4"
16
+ gem 'simplecov', ">= 0"
17
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,40 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.2.7)
5
+ i18n (~> 0.6)
6
+ multi_json (~> 1.0)
7
+ git (1.2.5)
8
+ i18n (0.6.0)
9
+ jeweler (1.8.4)
10
+ bundler (~> 1.0)
11
+ git (>= 1.2.5)
12
+ rake
13
+ rdoc
14
+ json (1.7.4)
15
+ log4r (1.1.10)
16
+ multi_json (1.3.6)
17
+ rake (0.9.2.2)
18
+ rdoc (3.12)
19
+ json (~> 1.4)
20
+ shoulda (3.1.1)
21
+ shoulda-context (~> 1.0)
22
+ shoulda-matchers (~> 1.2)
23
+ shoulda-context (1.0.0)
24
+ shoulda-matchers (1.2.0)
25
+ activesupport (>= 3.0.0)
26
+ simplecov (0.6.4)
27
+ multi_json (~> 1.0)
28
+ simplecov-html (~> 0.5.3)
29
+ simplecov-html (0.5.3)
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ jeweler (~> 1.8.4)
36
+ log4r
37
+ rdoc (~> 3.12)
38
+ shoulda
39
+ shoulda-context
40
+ simplecov
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Lauren Voswinkel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,31 @@
1
+ = easy-log4r
2
+
3
+ easy-log4r is a quick and simple way to start using Log4r fast. It quickly and easily creates a default logger, as well as class and instance functions that can be used to access it. In addition, it also provides a simple way to disable logging, for whatever reason, without needing to actually remove or comment out the logging code you, hopefully, peppered through your code.
4
+
5
+ To get started simply `include EasyLog4r::EasyLogger` after `require easy-log4r` in your class and you're good to go!
6
+
7
+ To disable logging you can `include EasyLog4r::NullLogger`. You don't need to remove the EasyLogger you include to start logging, but you can if you want to.
8
+
9
+ The default logger is created using the base class's name, so if you want to customize a particular logger's outputters using an XML or YAML file, feel free to do so using the normal methods, remembering to give the logger the class's name. (ex: 'MyClass')
10
+
11
+ That's it! Quick, simple, easy logging using log4r.
12
+
13
+ == Upcoming updates
14
+
15
+ * Ability to utilize customized Outputters and Formatters as defaults for even easier customized logging.
16
+
17
+ == Contributing to easy-log4r
18
+
19
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
20
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
21
+ * Fork the project.
22
+ * Start a feature/bugfix branch.
23
+ * Commit and push until you are happy with your contribution.
24
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
25
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
26
+
27
+ == Copyright
28
+
29
+ Copyright (c) 2012 Lauren Voswinkel. See LICENSE.txt for
30
+ further details.
31
+
data/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "easy_log4r"
18
+ gem.homepage = "http://github.com/valarissa/easy_log4r"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Easy logging using Log4r}
21
+ gem.description = %Q{Quick, simple, easy logging with log4r that can easily be toggled}
22
+ gem.email = "lvoswink@gmail.com"
23
+ gem.authors = ["Lauren Voswinkel"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ task :default => :test
36
+
37
+ require 'rdoc/task'
38
+ Rake::RDocTask.new do |rdoc|
39
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
+
41
+ rdoc.rdoc_dir = 'rdoc'
42
+ rdoc.title = "easy-log4r #{version}"
43
+ rdoc.rdoc_files.include('README*')
44
+ rdoc.rdoc_files.include('lib/**/*.rb')
45
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
@@ -0,0 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "easy_log4r"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Lauren Voswinkel"]
12
+ s.date = "2012-07-30"
13
+ s.description = "Quick, simple, easy logging with log4r that can easily be toggled"
14
+ s.email = "lvoswink@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "easy_log4r.gemspec",
28
+ "lib/easy_log4r.rb",
29
+ "lib/easy_log4r/easy_logger.rb",
30
+ "lib/easy_log4r/logger.rb",
31
+ "lib/easy_log4r/null_logger.rb",
32
+ "test/helper.rb",
33
+ "test/test_easy_logger.rb",
34
+ "test/test_logger.rb",
35
+ "test/test_null_logger.rb"
36
+ ]
37
+ s.homepage = "http://github.com/valarissa/easy_log4r"
38
+ s.licenses = ["MIT"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = "1.8.24"
41
+ s.summary = "Easy logging using Log4r"
42
+
43
+ if s.respond_to? :specification_version then
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<log4r>, [">= 0"])
48
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
49
+ s.add_development_dependency(%q<shoulda-context>, [">= 0"])
50
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
51
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
52
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
53
+ else
54
+ s.add_dependency(%q<log4r>, [">= 0"])
55
+ s.add_dependency(%q<shoulda>, [">= 0"])
56
+ s.add_dependency(%q<shoulda-context>, [">= 0"])
57
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
58
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
59
+ s.add_dependency(%q<simplecov>, [">= 0"])
60
+ end
61
+ else
62
+ s.add_dependency(%q<log4r>, [">= 0"])
63
+ s.add_dependency(%q<shoulda>, [">= 0"])
64
+ s.add_dependency(%q<shoulda-context>, [">= 0"])
65
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
66
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
67
+ s.add_dependency(%q<simplecov>, [">= 0"])
68
+ end
69
+ end
70
+
@@ -0,0 +1,5 @@
1
+ module EasyLog4r::EasyLogger
2
+ def self.included(base)
3
+ EasyLog4r::Logger.add_logger(base, EasyLog4r::Logger.get_logger(base))
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ class EasyLog4r::Logger
2
+ require 'log4r'
3
+ include Log4r
4
+
5
+ def self.add_logger(base, logger)
6
+ base.class_variable_set(:@@log4r, logger)
7
+ base.instance_eval{ def log4r; class_variable_get(:@@log4r); end }
8
+ base.class_eval{ def log4r; class_variable_get(:@@log4r); end }
9
+ end
10
+
11
+ def self.default_logger(name)
12
+ logger = null_logger(name)
13
+ formatter = Log4r::PatternFormatter.new(:pattern => "[%l] %d %c :: %m")
14
+ logger.outputters = [Log4r::StdoutOutputter.new(:formatter => formatter),
15
+ Log4r::StderrOutputter.new(:formatter => formatter)]
16
+ return logger
17
+ end
18
+
19
+ def self.null_logger(name)
20
+ logger = Log4r::Logger.new(name)
21
+ logger.outputters = []
22
+
23
+ return logger
24
+ end
25
+
26
+ def self.get_logger(base, null=false)
27
+ clas = base.to_s
28
+ logger = null ? null_logger(clas) : Log4r::Logger[clas]
29
+ return logger || default_logger(clas)
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ module EasyLog4r::NullLogger
2
+ def self.included(base)
3
+ EasyLog4r::Logger.add_logger(base, EasyLog4r::Logger.get_logger(base, :null))
4
+ end
5
+ end
data/lib/easy_log4r.rb ADDED
@@ -0,0 +1,5 @@
1
+ class EasyLog4r
2
+ require 'easy_log4r/logger'
3
+ require 'easy_log4r/easy_logger'
4
+ require 'easy_log4r/null_logger'
5
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter "/test/"
4
+ end
5
+
6
+ require 'rubygems'
7
+ require 'bundler'
8
+ begin
9
+ Bundler.setup(:default, :development)
10
+ rescue Bundler::BundlerError => e
11
+ $stderr.puts e.message
12
+ $stderr.puts "Run `bundle install` to install missing gems"
13
+ exit e.status_code
14
+ end
15
+ require 'test/unit'
16
+ require 'shoulda'
17
+
18
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
19
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
20
+ require 'easy_log4r'
21
+
22
+ class Test::Unit::TestCase
23
+ end
@@ -0,0 +1,21 @@
1
+ require 'helper'
2
+
3
+ class BaseClass
4
+ end
5
+
6
+ class TestEasyLogger < Test::Unit::TestCase
7
+
8
+ def include_logger
9
+ BaseClass.class_eval{ include EasyLog4r::EasyLogger }
10
+ end
11
+
12
+ should "create log4r method on base class" do
13
+ include_logger
14
+ assert_respond_to BaseClass, :log4r
15
+ end
16
+
17
+ should "create log4r method on class instance" do
18
+ include_logger
19
+ assert_respond_to BaseClass.new, :log4r
20
+ end
21
+ end
@@ -0,0 +1,42 @@
1
+ require 'helper'
2
+
3
+ class BaseClass
4
+ end
5
+
6
+ class TestLogger < Test::Unit::TestCase
7
+ context "self.get_logger" do
8
+ should "return a Log4r::Logger" do
9
+ assert EasyLog4r::Logger.get_logger(BaseClass).is_a?(Log4r::Logger)
10
+ end
11
+
12
+ should "return a Log4r::Logger with the name 'BaseClass'" do
13
+ logger = EasyLog4r::Logger.get_logger(BaseClass)
14
+ assert logger.name == 'BaseClass'
15
+ end
16
+
17
+ should "return a Log4r::Logger with no Outputters if specified" do
18
+ logger = EasyLog4r::Logger.get_logger(BaseClass, :null)
19
+ assert logger.outputters.length == 0
20
+ end
21
+
22
+ should "return an existing Log4r::Logger if one exists" do
23
+ orig_logger = Log4r::Logger.new('BaseClass')
24
+ logger = EasyLog4r::Logger.get_logger(BaseClass)
25
+ assert logger == orig_logger
26
+ end
27
+ end
28
+
29
+ context "self.default_logger" do
30
+ should "return a Log4r::Logger with outputters" do
31
+ logger = EasyLog4r::Logger.default_logger('BaseClass')
32
+ assert logger.outputters.length != 0
33
+ end
34
+ end
35
+
36
+ context "self.null_logger" do
37
+ should "return a Log4r::Logger with no outputters" do
38
+ logger = EasyLog4r::Logger.null_logger('BaseClass')
39
+ assert logger.outputters.length == 0
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,21 @@
1
+ require 'helper'
2
+
3
+ class BaseClass
4
+ end
5
+
6
+ class TestNullLogger < Test::Unit::TestCase
7
+
8
+ def include_logger
9
+ BaseClass.class_eval{ include EasyLog4r::NullLogger }
10
+ end
11
+
12
+ should "create log4r method on base class" do
13
+ include_logger
14
+ assert_respond_to BaseClass, :log4r
15
+ end
16
+
17
+ should "create log4r method on class instance" do
18
+ include_logger
19
+ assert_respond_to BaseClass.new, :log4r
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: easy_log4r
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Lauren Voswinkel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: log4r
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: shoulda
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: shoulda-context
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rdoc
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '3.12'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '3.12'
78
+ - !ruby/object:Gem::Dependency
79
+ name: jeweler
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 1.8.4
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.8.4
94
+ - !ruby/object:Gem::Dependency
95
+ name: simplecov
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: Quick, simple, easy logging with log4r that can easily be toggled
111
+ email: lvoswink@gmail.com
112
+ executables: []
113
+ extensions: []
114
+ extra_rdoc_files:
115
+ - LICENSE.txt
116
+ - README.rdoc
117
+ files:
118
+ - .document
119
+ - Gemfile
120
+ - Gemfile.lock
121
+ - LICENSE.txt
122
+ - README.rdoc
123
+ - Rakefile
124
+ - VERSION
125
+ - easy_log4r.gemspec
126
+ - lib/easy_log4r.rb
127
+ - lib/easy_log4r/easy_logger.rb
128
+ - lib/easy_log4r/logger.rb
129
+ - lib/easy_log4r/null_logger.rb
130
+ - test/helper.rb
131
+ - test/test_easy_logger.rb
132
+ - test/test_logger.rb
133
+ - test/test_null_logger.rb
134
+ homepage: http://github.com/valarissa/easy_log4r
135
+ licenses:
136
+ - MIT
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ! '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ segments:
148
+ - 0
149
+ hash: -759292738703420716
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ! '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 1.8.24
159
+ signing_key:
160
+ specification_version: 3
161
+ summary: Easy logging using Log4r
162
+ test_files: []