ougai 1.5.4 → 1.5.5

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: 97be7511c1c17536603cf512a2f8c107e40ff021
4
- data.tar.gz: e2c08a3c8e6833e0ef2622d0fb264b75dba77e94
3
+ metadata.gz: da3e50121cd1ca747fdf84a266ab60d0fe8d71eb
4
+ data.tar.gz: 3c93d87d0c32eb0e6a30c0ab0577b537476b3de8
5
5
  SHA512:
6
- metadata.gz: d457ca8fbff8a3a22003eb9c4878b7b0af931a04d58d89f950733ab80a22de0095f5ee5a16d4c6f8b7695d327434ea12c9629710656df3a32c9543bf1de5c39b
7
- data.tar.gz: '0974027ba5cd59d0e8418abb5a2e5b89ee0145cd7cf002d9ea497c871b4c2305952ac3bf56bb06ac5298eb5d8b74f20e2d674aacd8d62e5081861aa4fc853dc8'
6
+ metadata.gz: 3c7eed367fc984d280ac8f4cfb802c1836ec2918b57dc1c233ab4084585ef115e12d451cafd7c10d0014be7d2d31ea92c877bef8b4e1a2ab02a8947c0b180e42
7
+ data.tar.gz: 875f603ca33e5349c2edc0a2cec508b39afb4fab9db4545fec82369c1c7a8e383abcd2afb48da8ce597e669eaca357f686a7cc9e633920ac3a5a1d24ae097f10
data/README.md CHANGED
@@ -197,7 +197,7 @@ But if the field's type is *Array*, both with_field value and logging value are
197
197
 
198
198
  ### Create a child logger
199
199
 
200
- `logger.child(with_fields)` creates a child logger of self. Its argument `with_fields` add to all logs the child logger outputs. A child logger can also create its child logger.
200
+ `logger.child(with_fields)` creates a child logger of self. Its argument `with_fields` add to all logs the child logger outputs. A child logger can also create its child logger. If you pass a block to this method, the child logger will be yielded to it.
201
201
 
202
202
  ```ruby
203
203
  logger = Ougai::Logger.new(STDOUT)
@@ -212,6 +212,12 @@ gc_logger = child_logger.child({ kind: 'detail' })
212
212
  child_logger.info('Created grand child logger')
213
213
 
214
214
  gc_logger.debug('something detail', age: 34, weight: 72)
215
+
216
+ gc_logger.child({ mode: 'processed' }) do |gcc_logger|
217
+ gcc_logger.info('Great-grandchild logger that will be cleaned up on block exit.')
218
+
219
+ :some_return_value
220
+ end
215
221
  ```
216
222
 
217
223
  ```json
@@ -219,6 +225,7 @@ gc_logger.debug('something detail', age: 34, weight: 72)
219
225
  {"name":"Mike","hostname":"mint2","pid":8342,"level":30,"time":"2017-08-01T22:07:20.400+09:00","v":0,"app":"yourapp","tags":["service","user"],"kind":"logic","msg":"Created a user"}
220
226
  {"name":"main","hostname":"mint2","pid":8342,"level":30,"time":"2017-08-01T22:07:20.400+09:00","v":0,"app":"yourapp","tags":["service","user"],"kind":"logic","msg":"Created grand child logger"}
221
227
  {"name":"main","hostname":"mint2","pid":8342,"level":20,"time":"2017-08-01T22:07:20.400+09:00","v":0,"app":"yourapp","tags":["service","user"],"kind":"detail","age":34,"weight":72,"msg":"something detail"}
228
+ {"name":"main","hostname":"mint2","pid":8342,"level":20,"time":"2017-08-01T22:07:20.400+09:00","v":0,"app":"yourapp","tags":["service","user"],"kind":"detail","mode":"processed","msg":"Great-grandchild logger that will be cleaned up on block exit."}
222
229
  ```
223
230
 
224
231
  If any field exists in both parent log and child log, the parent value is overridden or merged by child value.
@@ -80,7 +80,13 @@ module Ougai
80
80
  # @param fields [Hash] The fields appending to all logs
81
81
  # @return [ChildLogger] A created child logger
82
82
  def child(fields = {})
83
- ChildLogger.new(self, fields)
83
+ ch = ChildLogger.new(self, fields)
84
+
85
+ if !block_given?
86
+ ch
87
+ else
88
+ yield ch
89
+ end
84
90
  end
85
91
 
86
92
  # @private
@@ -1,3 +1,3 @@
1
1
  module Ougai
2
- VERSION = "1.5.4"
2
+ VERSION = "1.5.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ougai
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshimitsu Takahashi