smart_logger_wrapper 0.1.0 → 0.1.1

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: 9e74dde7e2e9f462afec29ffccaf4066fffe25f4
4
- data.tar.gz: bcbbe35862489fe01aa3629cbe8d6026f09889aa
3
+ metadata.gz: 444b6317f04b10930e9ad6ec0d0efde371ecc9ca
4
+ data.tar.gz: 39aa6ff2667da7d5f8ec1b83d8bfb3bdd09e3307
5
5
  SHA512:
6
- metadata.gz: aeef4e5d071ba8d79f3ca8c335c82b31430759090dc0e38ae95ce7f8d0ea3a64bad34a82f5fe542dcf5411e671397be23d04f386ac3d0e0ef6f7fc04edc1de95
7
- data.tar.gz: 32f1a2b6ddc5fb8ba57a93b3e7aaec27f4fdbad2dcd3be215968a4a48844613aed9cc49e64ce67ed9af21530ae05daef93d82654623c1085a62272ce664eab1a
6
+ metadata.gz: 07f7e3686b7e480b09b20cd39f1a09b62af4b004073792a2f46076ad841b65ede344f3cc28db455fd9fed4ac6a42c7d4abd318295f2e1e2be28ac9606daa5d4f
7
+ data.tar.gz: 5da56581d007acb6d0646e817fbf2d85a78b52b72f0352810172a59cb330eba5fb059d0786970598c59fa81418e7c8b6047026d357c730b85048f7de9ac8c7a9
data/README.md CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
 
23
23
  ### For Ruby on Rails
24
24
 
25
- Wrap your logger with `SmartLoggerWrapper`, for example:
25
+ Wrap your logger with `SmartLoggerWrapper`, for example, in `config/environments/production.rb`:
26
26
 
27
27
  ```diff
28
28
  - config.logger = Logger.new('log/production.log', 'daily')
@@ -31,6 +31,14 @@ Wrap your logger with `SmartLoggerWrapper`, for example:
31
31
 
32
32
  Note that it is strongly recommended to use the wrapper for all environments so that you can avoid exceptions such as `NoMethodError` due to the unique features of this library.
33
33
 
34
+ You may want to put log messages to STDOUT in the development environment. Then:
35
+
36
+ ```
37
+ logger = ActiveSupport::Logger.new("log/development.log")
38
+ logger.extend ActiveSupport::Logger.broadcast(ActiveSupport::Logger.new(STDOUT))
39
+ config.logger = SmartLoggerWrapper.new(logger)
40
+ ```
41
+
34
42
  ## Usage
35
43
 
36
44
  ### Basic
@@ -1,3 +1,3 @@
1
1
  class SmartLoggerWrapper
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -21,21 +21,21 @@ class SmartLoggerWrapper
21
21
  @options = options
22
22
  end
23
23
 
24
- def log(severity, *args, &block)
25
- _log(severity, *args, &block)
24
+ def add(severity, *args, &block)
25
+ _add(severity, *args, &block)
26
26
  end
27
- alias add log
27
+ alias log add
28
28
 
29
29
  SEVERITY_MAPPING.each do |severity_name, severity|
30
30
  define_method(severity_name) do |*args, &block|
31
- _log(severity, *args, &block)
31
+ _add(severity, *args, &block)
32
32
  end
33
33
  end
34
34
 
35
35
  private
36
36
 
37
37
  # All methods calling this must have the synchronized call stack depth so that this can show neat positions and backtraces
38
- def _log(severity, *args, &block)
38
+ def _add(severity, *args, &block)
39
39
  messages = args.map { |arg| to_message(arg) }
40
40
  messages << to_message(block.call) if block_given?
41
41
  begin
@@ -49,7 +49,7 @@ class SmartLoggerWrapper
49
49
  false
50
50
  end.tap do |succeeded|
51
51
  messages.each do |message|
52
- logger.log(severity, nil, message)
52
+ logger.add(severity, nil, message)
53
53
  end
54
54
  end
55
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_logger_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akihiro Katsura