composite_logger 1.1.0 → 1.2.0

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +43 -6
  3. data/lib/composite_logger.rb +3 -3
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 94e99b1affa95a055bb3b327a2f4beb21c0e2b4e
4
- data.tar.gz: 3e29dc2b324016aa1d58e1f6bc98874d13ff8898
3
+ metadata.gz: ed3a179aeb150269bf58545b019e32e1e9362a9a
4
+ data.tar.gz: 90df1313cb9170ae96e2c0ac5732e653a02b3d72
5
5
  SHA512:
6
- metadata.gz: e0dcb481420b18991bc063f80c04fc7ae659945030466031f946634ab2729f2ea954ea971407596d652179bf79572ead81f433d2c8a3ee6a7d64663dae88958e
7
- data.tar.gz: a8a1f1d501772f324d8a084174a156be24577f7a2d145b16e7e8e9d2df99a3322cb6c23cce718244d2272950539602abb6ecc363f324715c0c3813648b774d33
6
+ metadata.gz: 38055480323f2c553c669aadd122f604c122270e5a98c5098d23085245d9608c7e114672f577df6c59a5f3060d4979686bdda06317a2e113443627bf9a59326b
7
+ data.tar.gz: c6fb97c69d7f0f7d8c026e9f16484924c1552cc85b57e734873fa5d1ab39be14d73d317a0f849173ec8ff94e44cd8c3f4c2d6bea0d596292048daeec2fda15ba
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # CompositeLogger
1
+ # Composite Logger
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/composite_logger`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ _One log to rule them all._
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,11 +20,46 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ CompositeLogger implements the standard Logger interface so it can be a drop-in replacement for your current logger:
24
+
25
+ ```ruby
26
+ require "composite_logger"
27
+
28
+ stdout_logger = Logger.new(STDOUT)
29
+ stderr_logger = Logger.new(STDERR)
30
+ file_logger = Logger.new("logfile.log")
31
+
32
+ stdout_logger.level = Logger::DEBUG
33
+ stdout_logger.level = Logger::ERROR
34
+ file_logger.level = Logger::ERROR
35
+
36
+ composite_logger = CompositeLogger.new(stdout_logger, stderr_logger)
37
+ composite_logger.loggers << file_logger
38
+ composite_logger.level = Logger::INFO
39
+ composite_logger.debug("This won't be logged becase logger level is INFO")
40
+ composite_logger.info("This will be logged")
41
+ composite_logger << "Message using 'dump' syntax"
42
+ composite_logger.error do
43
+ "An error message using block syntax"
44
+ end
45
+
46
+ ```
47
+
48
+ ### Rails
49
+
50
+ CompositeLogger can be integrated within your Rails application:
51
+
52
+ ```ruby
53
+ # config/initializers/logger.rb
54
+ Rails.logger = CompositeLogger.new(Rails.logger, RollbarLogger.new)
55
+ ```
56
+
57
+ That's all you need to use CompositeLogger with Rails.
58
+
26
59
 
27
60
  ## Development
28
61
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
62
+ After checking out the repo, run `script/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `script/console` for an interactive prompt that will allow you to experiment.
30
63
 
31
64
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
65
 
@@ -39,3 +72,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/fertap
39
72
 
40
73
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
74
 
75
+ ## Author
76
+
77
+ Fernando Tapia Rico, [@fertapric](https://twitter.com/fertapric)
78
+
@@ -3,7 +3,7 @@ require "logger"
3
3
  class CompositeLogger < Logger
4
4
  VERSION = [
5
5
  VERSION_MAJOR = 1,
6
- VERSION_MINOR = 1,
6
+ VERSION_MINOR = 2,
7
7
  VERSION_TINY = 0,
8
8
  VERSION_PRE = nil
9
9
  ].compact.join(".")
@@ -38,8 +38,8 @@ class CompositeLogger < Logger
38
38
  @loggers ||= []
39
39
  end
40
40
 
41
- def <<(logger)
42
- loggers << logger
41
+ def <<(message)
42
+ loggers.each { |logger| logger << message }
43
43
  end
44
44
 
45
45
  def add(severity, message = nil, progname = nil, &block)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: composite_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Tapia Rico
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-21 00:00:00.000000000 Z
11
+ date: 2015-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.8'
55
- description: One log to rule them all. Log using multiple Logger instances.
55
+ description: Logging using the Composite pattern.
56
56
  email:
57
57
  - fertapric@gmail.com
58
58
  executables: []
@@ -85,5 +85,5 @@ rubyforge_project:
85
85
  rubygems_version: 2.4.5
86
86
  signing_key:
87
87
  specification_version: 4
88
- summary: Log using multiple logger instances.
88
+ summary: Composite Logger
89
89
  test_files: []