ougai 1.9.1 → 2.1.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.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +31 -28
- data/LICENSE.txt +1 -1
- data/README.md +24 -15
- data/lib/ougai/logging.rb +2 -0
- data/lib/ougai/version.rb +1 -1
- metadata +17 -63
- data/spec/child_logger_spec.rb +0 -608
- data/spec/formatters/base_spec.rb +0 -98
- data/spec/formatters/bunyan_spec.rb +0 -157
- data/spec/formatters/pino_spec.rb +0 -168
- data/spec/formatters/readable_spec.rb +0 -142
- data/spec/logger_spec.rb +0 -765
- data/spec/logging_spec.rb +0 -98
- data/spec/ougai_spec.rb +0 -7
- data/spec/spec_helper.rb +0 -78
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b7960bbde8ec8ae6408bd7c151d5d01f55f7710c20256a2f0b0d8d32450f8fd7
|
|
4
|
+
data.tar.gz: 49a458b9cae86420a038f8f17ca835f6de8680f3fdf2e868aa46607b7939e0ab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e082c22775e3ad0a08de9faf6ba563735c12761ba7fc72ab5da6dc10263533c522a76543dd017ab35ad3420f69ac16940298d8dc335607adb7701340f42c0c2e
|
|
7
|
+
data.tar.gz: 33687bb680f760e2329630acbacea15a6b5931776bdc26952ef0eec09959e161a938ba2444d49e5d76e289a7ae11bdd6fdc971a0f9945aae51fff5a413c216dc
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,53 +1,56 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
ougai (1.
|
|
5
|
-
|
|
4
|
+
ougai (2.1.0)
|
|
5
|
+
logger (~> 1.5)
|
|
6
|
+
oj (~> 3.17)
|
|
6
7
|
|
|
7
8
|
GEM
|
|
8
9
|
remote: https://rubygems.org/
|
|
9
10
|
specs:
|
|
10
|
-
amazing_print (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
json (2.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
rspec
|
|
22
|
-
rspec-
|
|
23
|
-
|
|
11
|
+
amazing_print (2.0.0)
|
|
12
|
+
bigdecimal (4.1.2)
|
|
13
|
+
diff-lcs (1.6.2)
|
|
14
|
+
docile (1.4.1)
|
|
15
|
+
json (2.20.0)
|
|
16
|
+
logger (1.7.0)
|
|
17
|
+
oj (3.17.3)
|
|
18
|
+
bigdecimal (>= 3.0)
|
|
19
|
+
ostruct (>= 0.2)
|
|
20
|
+
ostruct (0.6.3)
|
|
21
|
+
rake (13.4.2)
|
|
22
|
+
rspec (3.13.2)
|
|
23
|
+
rspec-core (~> 3.13.0)
|
|
24
|
+
rspec-expectations (~> 3.13.0)
|
|
25
|
+
rspec-mocks (~> 3.13.0)
|
|
26
|
+
rspec-core (3.13.6)
|
|
27
|
+
rspec-support (~> 3.13.0)
|
|
28
|
+
rspec-expectations (3.13.5)
|
|
24
29
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
25
|
-
rspec-support (~> 3.
|
|
26
|
-
rspec-mocks (3.
|
|
30
|
+
rspec-support (~> 3.13.0)
|
|
31
|
+
rspec-mocks (3.13.8)
|
|
27
32
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
28
|
-
rspec-support (~> 3.
|
|
29
|
-
rspec-support (3.
|
|
33
|
+
rspec-support (~> 3.13.0)
|
|
34
|
+
rspec-support (3.13.7)
|
|
30
35
|
simplecov (0.17.1)
|
|
31
36
|
docile (~> 1.1)
|
|
32
37
|
json (>= 1.8, < 3)
|
|
33
38
|
simplecov-html (~> 0.10.0)
|
|
34
39
|
simplecov-html (0.10.2)
|
|
35
|
-
timecop (0.9.
|
|
36
|
-
yard (0.9.
|
|
40
|
+
timecop (0.9.11)
|
|
41
|
+
yard (0.9.44)
|
|
37
42
|
|
|
38
43
|
PLATFORMS
|
|
39
|
-
|
|
40
|
-
ruby
|
|
44
|
+
x86_64-linux
|
|
41
45
|
|
|
42
46
|
DEPENDENCIES
|
|
43
47
|
amazing_print
|
|
44
|
-
bundler (>= 2.1.4)
|
|
45
48
|
ougai!
|
|
46
|
-
rake (
|
|
47
|
-
rspec (
|
|
49
|
+
rake (~> 13.2)
|
|
50
|
+
rspec (~> 3.13)
|
|
48
51
|
simplecov (< 0.18)
|
|
49
52
|
timecop
|
|
50
53
|
yard
|
|
51
54
|
|
|
52
55
|
BUNDLED WITH
|
|
53
|
-
2.
|
|
56
|
+
2.3.3
|
data/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2016-
|
|
3
|
+
Copyright (c) 2016-2026 Toshimitsu Takahashi
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
|
@@ -2,14 +2,12 @@ Ougai
|
|
|
2
2
|
=====
|
|
3
3
|
|
|
4
4
|
[](https://badge.fury.io/rb/ougai)
|
|
5
|
-
[](https://codeclimate.com/github/tilfin/ougai)
|
|
8
|
-
[](https://codeclimate.com/github/tilfin/ougai/coverage)
|
|
5
|
+
[](http://www.rubydoc.info/gems/ougai/)
|
|
6
|
+
[](https://github.com/tilfin/ougai/actions/workflows/ci.yml)
|
|
9
7
|
|
|
10
|
-
A structured logging system is capable of handling a message, structured data or an exception easily.
|
|
11
|
-
It has JSON formatters compatible with [Bunyan](https://github.com/trentm/node-bunyan) or [pino](https://github.com/pinojs/pino) for Node.js and
|
|
12
|
-
human
|
|
8
|
+
A structured logging system that is capable of handling a message, structured data, or an exception easily.
|
|
9
|
+
It has JSON formatters compatible with [Bunyan](https://github.com/trentm/node-bunyan) or [pino](https://github.com/pinojs/pino) for Node.js, and a
|
|
10
|
+
human-readable formatter with [Amazing Print](https://github.com/amazing-print/amazing_print) for the console.
|
|
13
11
|
|
|
14
12
|
## Installation
|
|
15
13
|
|
|
@@ -33,14 +31,13 @@ $ gem install ougai
|
|
|
33
31
|
|
|
34
32
|
## Usage
|
|
35
33
|
|
|
36
|
-
**Ougai::Logger** is sub-class of
|
|
37
|
-
All arguments of the `initialize` pass through
|
|
34
|
+
**Ougai::Logger** is a sub-class of the standard [Logger](https://ruby-doc.org/stdlib-2.4.1/libdoc/logger/rdoc/Logger.html) in Ruby.
|
|
35
|
+
All arguments of the `initialize` pass through to **::Logger**.
|
|
38
36
|
|
|
39
37
|
```ruby
|
|
40
|
-
require 'rubygems'
|
|
41
38
|
require 'ougai'
|
|
42
39
|
|
|
43
|
-
logger = Ougai::Logger.new(
|
|
40
|
+
logger = Ougai::Logger.new($stdout)
|
|
44
41
|
```
|
|
45
42
|
|
|
46
43
|
### TRACE level
|
|
@@ -176,7 +173,7 @@ logger.fatal do
|
|
|
176
173
|
end
|
|
177
174
|
```
|
|
178
175
|
|
|
179
|
-
To specify more than one
|
|
176
|
+
To specify more than one message, exception, and custom data, the block returns them as an array.
|
|
180
177
|
|
|
181
178
|
### Adding custom fields to all logs
|
|
182
179
|
|
|
@@ -194,7 +191,18 @@ logger.info('Hello!', user: { name: 'Jiro' }, version: '2.3')
|
|
|
194
191
|
```
|
|
195
192
|
|
|
196
193
|
If any field of with_fields is specified in each log, the field is overridden.
|
|
197
|
-
|
|
194
|
+
If the field's type is *Array*, both with_field value and logging value are merged with `concat` and `uniq`.
|
|
195
|
+
|
|
196
|
+
If the field's type is *Hash*, then values are merged recursively.
|
|
197
|
+
|
|
198
|
+
```ruby
|
|
199
|
+
logger.with_fields = { version: '1.1.0', user: { name: 'Taro' } }
|
|
200
|
+
logger.debug(user: { age: 19 })
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
```json
|
|
204
|
+
{"name":"test","hostname":"mint","pid":30182,"level":20,"time":"2017-07-22T20:52:12.332+09:00","v":0,"version":"1.1.0","msg":"No message","user":{"name":"Taro","age":19}}
|
|
205
|
+
```
|
|
198
206
|
|
|
199
207
|
### Create a child logger
|
|
200
208
|
|
|
@@ -242,6 +250,8 @@ child_logger.debug('This is not outputted')
|
|
|
242
250
|
|
|
243
251
|
If any field exists in both parent log and child log, the parent value is overridden or merged by child value.
|
|
244
252
|
|
|
253
|
+
If the field's type is *Hash*, then values are merged recursively.
|
|
254
|
+
|
|
245
255
|
### Hook before logging
|
|
246
256
|
|
|
247
257
|
Setting `before_log` of logger or child an *lambda* with `data` field, a process can be run before log each output.
|
|
@@ -344,7 +354,6 @@ gem 'amazing_print'
|
|
|
344
354
|
Set *Ougai::Formatters::Readable* instance to `formatter` accessor
|
|
345
355
|
|
|
346
356
|
```ruby
|
|
347
|
-
require 'rubygems'
|
|
348
357
|
require 'ougai'
|
|
349
358
|
|
|
350
359
|
logger = Ougai::Logger.new(STDOUT)
|
|
@@ -353,7 +362,7 @@ logger.formatter = Ougai::Formatters::Readable.new
|
|
|
353
362
|
|
|
354
363
|
### Screen result example
|
|
355
364
|
|
|
356
|
-

|
|
357
366
|
|
|
358
367
|
|
|
359
368
|
## How to use with famous products, services and libraries
|
data/lib/ougai/logging.rb
CHANGED
|
@@ -120,6 +120,8 @@ module Ougai
|
|
|
120
120
|
base_data.merge!(inferior_data) do |_, base_v, inferior_v|
|
|
121
121
|
if base_v.is_a?(Array) and inferior_v.is_a?(Array)
|
|
122
122
|
(inferior_v + base_v).uniq
|
|
123
|
+
elsif base_v.is_a?(Hash) and inferior_v.is_a?(Hash)
|
|
124
|
+
weak_merge!(base_v, inferior_v)
|
|
123
125
|
else
|
|
124
126
|
base_v
|
|
125
127
|
end
|
data/lib/ougai/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,71 +1,43 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ougai
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Toshimitsu Takahashi
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-06-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: logger
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '1.5'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '1.5'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ">="
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: 2.1.4
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - ">="
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: 2.1.4
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rake
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - ">="
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: 13.0.1
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - ">="
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: 13.0.1
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: rspec
|
|
28
|
+
name: oj
|
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
|
58
30
|
requirements:
|
|
59
|
-
- - "
|
|
31
|
+
- - "~>"
|
|
60
32
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 3.
|
|
62
|
-
type: :
|
|
33
|
+
version: '3.17'
|
|
34
|
+
type: :runtime
|
|
63
35
|
prerelease: false
|
|
64
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
37
|
requirements:
|
|
66
|
-
- - "
|
|
38
|
+
- - "~>"
|
|
67
39
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 3.
|
|
40
|
+
version: '3.17'
|
|
69
41
|
description: |2
|
|
70
42
|
A structured logging system is capable of handling a message, custom data or an exception easily.
|
|
71
43
|
It has JSON formatters compatible with Bunyan or pino for Node.js and human readable formatter with Amazing Print for console.
|
|
@@ -93,20 +65,11 @@ files:
|
|
|
93
65
|
- lib/ougai/serializers/json_jr_jackson.rb
|
|
94
66
|
- lib/ougai/serializers/json_oj.rb
|
|
95
67
|
- lib/ougai/version.rb
|
|
96
|
-
- spec/child_logger_spec.rb
|
|
97
|
-
- spec/formatters/base_spec.rb
|
|
98
|
-
- spec/formatters/bunyan_spec.rb
|
|
99
|
-
- spec/formatters/pino_spec.rb
|
|
100
|
-
- spec/formatters/readable_spec.rb
|
|
101
|
-
- spec/logger_spec.rb
|
|
102
|
-
- spec/logging_spec.rb
|
|
103
|
-
- spec/ougai_spec.rb
|
|
104
|
-
- spec/spec_helper.rb
|
|
105
68
|
homepage: https://github.com/tilfin/ougai
|
|
106
69
|
licenses:
|
|
107
70
|
- MIT
|
|
108
71
|
metadata: {}
|
|
109
|
-
post_install_message:
|
|
72
|
+
post_install_message:
|
|
110
73
|
rdoc_options: []
|
|
111
74
|
require_paths:
|
|
112
75
|
- lib
|
|
@@ -114,25 +77,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
114
77
|
requirements:
|
|
115
78
|
- - ">="
|
|
116
79
|
- !ruby/object:Gem::Version
|
|
117
|
-
version:
|
|
80
|
+
version: 3.1.0
|
|
118
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
82
|
requirements:
|
|
120
83
|
- - ">="
|
|
121
84
|
- !ruby/object:Gem::Version
|
|
122
85
|
version: '0'
|
|
123
86
|
requirements: []
|
|
124
|
-
rubygems_version: 3.
|
|
125
|
-
signing_key:
|
|
87
|
+
rubygems_version: 3.3.3
|
|
88
|
+
signing_key:
|
|
126
89
|
specification_version: 4
|
|
127
90
|
summary: JSON logger compatible with node-bunyan or pino is capable of handling structured
|
|
128
91
|
data easily.
|
|
129
|
-
test_files:
|
|
130
|
-
- spec/child_logger_spec.rb
|
|
131
|
-
- spec/logging_spec.rb
|
|
132
|
-
- spec/ougai_spec.rb
|
|
133
|
-
- spec/spec_helper.rb
|
|
134
|
-
- spec/formatters/pino_spec.rb
|
|
135
|
-
- spec/formatters/readable_spec.rb
|
|
136
|
-
- spec/formatters/base_spec.rb
|
|
137
|
-
- spec/formatters/bunyan_spec.rb
|
|
138
|
-
- spec/logger_spec.rb
|
|
92
|
+
test_files: []
|