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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9053d81db875e3d007c47d17c61f451d2c5373ba
4
- data.tar.gz: aec324fa8c19728d07ceee530a1dcc88a10a9b5a
3
+ metadata.gz: 1fac6b9d6d29180865ac0937c8c39f86c716af25
4
+ data.tar.gz: 3f70c78f17966bad92edbe300ec90d27491f5a8b
5
5
  SHA512:
6
- metadata.gz: 000d11c38ffefad76fb1a7f3829ad21ffa359a58baea45d2c698ecf844857428de7cd761a918ae01c0d5fbf7b6715df6e451e03e4b6f99fcd5f4fcb12503d6c7
7
- data.tar.gz: 85c300ccc030a4324224b8b7b89d8c0b0fb8815deeb4e67548ceecf9430df23ad6586db9e8c8d86b7c61d380a62d4fd25b2656121ca5544a3e758b0dc102a7cd
6
+ metadata.gz: e5ce7f7db093856ecdf3f0c22d61876baff65597cb30310a91e6b75b43febe323a1ba72b60ed604eca08a6f621e133581aeb88c0f3ec09a50e6d7a322b7d1e31
7
+ data.tar.gz: 324833b641124a2c9bf694d1a81b7a4230497cbe25e2b6ed54d066954d98ee0f033970c7072277d8ab12dae3dea96c5b535443687df6988e043b25c3dba0c13f
@@ -6,6 +6,10 @@ versions, as well as provide a rough history.
6
6
 
7
7
  #### Next Release
8
8
 
9
+ #### v1.1.0
10
+
11
+ * Added logger management module
12
+
9
13
  #### v1.0.0
10
14
 
11
15
  * Added documentation around all the classes, modules, constants and methods
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.0'
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
@@ -1,5 +1,6 @@
1
1
  require 'optional_logger/version'
2
2
  require 'optional_logger/logger'
3
+ require 'optional_logger/logger_management'
3
4
 
4
5
  # Top-level namespace for a library providing an optional logger and supporting
5
6
  # functionality around it
@@ -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
@@ -1,4 +1,4 @@
1
1
  module OptionalLogger
2
2
  # The version of the library
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  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.0.0
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 00:00:00.000000000 Z
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