optional_logger 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +29 -1
- data/lib/optional_logger.rb +1 -0
- data/lib/optional_logger/logger_management.rb +16 -0
- data/lib/optional_logger/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fac6b9d6d29180865ac0937c8c39f86c716af25
|
4
|
+
data.tar.gz: 3f70c78f17966bad92edbe300ec90d27491f5a8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5ce7f7db093856ecdf3f0c22d61876baff65597cb30310a91e6b75b43febe323a1ba72b60ed604eca08a6f621e133581aeb88c0f3ec09a50e6d7a322b7d1e31
|
7
|
+
data.tar.gz: 324833b641124a2c9bf694d1a81b7a4230497cbe25e2b6ed54d066954d98ee0f033970c7072277d8ab12dae3dea96c5b535443687df6988e043b25c3dba0c13f
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -36,7 +36,7 @@ accidentally altering the applications logger.
|
|
36
36
|
Add this line to your gem's gemspec file:
|
37
37
|
|
38
38
|
```ruby
|
39
|
-
spec.add_dependency 'optional_logger', '~> 1.
|
39
|
+
spec.add_dependency 'optional_logger', '~> 1.1'
|
40
40
|
```
|
41
41
|
|
42
42
|
Or install it yourself as:
|
@@ -91,6 +91,34 @@ logger.log(Logger::FATAL, "some message", "Program Name")
|
|
91
91
|
**Note:** You don't have to worry about setting up or cleaning up after the
|
92
92
|
logger as it is managed by the application that is using your library.
|
93
93
|
|
94
|
+
### Logger Management
|
95
|
+
|
96
|
+
We also provide a small module to aid with logger management within your gem if
|
97
|
+
you don't want to write your own logger management using the core logger
|
98
|
+
provided above. The following is an example of how might use it if you had a gem
|
99
|
+
called `my_foo_gem`.
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
require 'optional_logger'
|
103
|
+
|
104
|
+
module MyFooGem
|
105
|
+
include OptionalLogger::LoggerManagement
|
106
|
+
end
|
107
|
+
```
|
108
|
+
|
109
|
+
The above would enable consumers of your library to set the logger as follows.
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
MyFooGem.logger(some_application_logger)
|
113
|
+
```
|
114
|
+
|
115
|
+
It also enables you to access an `OptionalLogger::Logger` instance that wraps
|
116
|
+
the application logger they provided within your gem as follows.
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
MyFooGem.logger # => the optional logger wrapping some_application_logger
|
120
|
+
```
|
121
|
+
|
94
122
|
## Development
|
95
123
|
|
96
124
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
data/lib/optional_logger.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'optional_logger'
|
2
|
+
|
3
|
+
module OptionalLogger
|
4
|
+
module LoggerManagement
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def logger(logger = nil)
|
11
|
+
return @logger if @logger && logger.nil?
|
12
|
+
@logger = OptionalLogger::Logger.new(logger)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optional_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew De Ponte
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- bin/setup
|
74
74
|
- lib/optional_logger.rb
|
75
75
|
- lib/optional_logger/logger.rb
|
76
|
+
- lib/optional_logger/logger_management.rb
|
76
77
|
- lib/optional_logger/version.rb
|
77
78
|
- optional_logger.gemspec
|
78
79
|
homepage: http://github.com/Acornsgrow/optional_logger
|