twiglet 2.2.2 → 2.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +2 -1
- data/.github/workflows/gem-publish.yml +26 -0
- data/.github/workflows/ruby.yml +1 -1
- data/.rubocop.yml +1 -1
- data/README.md +3 -1
- data/lib/twiglet/formatter.rb +3 -0
- data/lib/twiglet/logger.rb +6 -3
- data/lib/twiglet/version.rb +1 -1
- data/test/formatter_test.rb +3 -0
- data/test/logger_test.rb +12 -2
- data/twiglet.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6b403959c8c42d8942d17af72a53419a68b8a90c0a805fbdec6703aa4e86d95
|
4
|
+
data.tar.gz: 7c99b71016b8f41ab0d82cfedcb376dd5704c77e1bdb7a00a99f48a89d1b2666
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e22959d3b8796813b6f4b789ae00cf8629b83b14b31a4f525babc3718d7462c93e961391f3322c39a15bd26d08a38194cd1dd6d025d5c4871ada864be4e52c5b
|
7
|
+
data.tar.gz: bcf49062251a7b68b20ef559c124e04928593fc5a004ad21cbfd3262a716f382bcc3b462ca338bfd628796e5c40d14bf4c543d430f4e9d7c542a6201a7639f2b
|
data/.github/CODEOWNERS
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
name: Publish Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
name: Build and Publish
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
- name: Set up Ruby 2.6
|
14
|
+
uses: actions/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
version: 2.6.x
|
17
|
+
- name: Publish to RubyGems
|
18
|
+
run: |
|
19
|
+
mkdir -p $HOME/.gem
|
20
|
+
touch $HOME/.gem/credentials
|
21
|
+
chmod 0600 $HOME/.gem/credentials
|
22
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
23
|
+
gem build *.gemspec
|
24
|
+
gem push *.gem
|
25
|
+
env:
|
26
|
+
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
data/.github/workflows/ruby.yml
CHANGED
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -22,7 +22,9 @@ A hash can optionally be passed in as a keyword argument for `default_properties
|
|
22
22
|
|
23
23
|
You may also provide an optional `output` keyword argument which should be an object with a `puts` method - like `$stdout`.
|
24
24
|
|
25
|
-
|
25
|
+
In addition, you can provide another optional keyword argument called `now`, which should be a function returning a `Time` string in ISO8601 format.
|
26
|
+
|
27
|
+
Lastly, you may provide the optional keyword argument `level` to initialize the logger with a severity threshold. Alternatively, the threshold can be updated at runtime by calling the `level` instance method.
|
26
28
|
|
27
29
|
The defaults for both `output` and `now` should serve for most uses, though you may want to override them for testing as we have done [here](test/logger_test.rb).
|
28
30
|
|
data/lib/twiglet/formatter.rb
CHANGED
data/lib/twiglet/logger.rb
CHANGED
@@ -14,17 +14,19 @@ module Twiglet
|
|
14
14
|
service_name,
|
15
15
|
default_properties: {},
|
16
16
|
now: -> { Time.now.utc },
|
17
|
-
output: $stdout
|
17
|
+
output: $stdout,
|
18
|
+
level: Logger::DEBUG
|
18
19
|
)
|
19
20
|
@service_name = service_name
|
20
21
|
@now = now
|
21
22
|
@output = output
|
23
|
+
@level = level
|
22
24
|
|
23
25
|
raise 'Service name is mandatory' \
|
24
26
|
unless service_name.is_a?(String) && !service_name.strip.empty?
|
25
27
|
|
26
28
|
formatter = Twiglet::Formatter.new(service_name, default_properties: default_properties, now: now)
|
27
|
-
super(output, formatter: formatter)
|
29
|
+
super(output, formatter: formatter, level: level)
|
28
30
|
end
|
29
31
|
|
30
32
|
def error(message = {}, error = nil, &block)
|
@@ -45,7 +47,8 @@ module Twiglet
|
|
45
47
|
Logger.new(@service_name,
|
46
48
|
default_properties: default_properties,
|
47
49
|
now: @now,
|
48
|
-
output: @output
|
50
|
+
output: @output,
|
51
|
+
level: @level)
|
49
52
|
end
|
50
53
|
|
51
54
|
alias_method :warning, :warn
|
data/lib/twiglet/version.rb
CHANGED
data/test/formatter_test.rb
CHANGED
@@ -17,6 +17,9 @@ describe Twiglet::Formatter do
|
|
17
17
|
it 'returns a formatted log from a string message' do
|
18
18
|
msg = @formatter.call('warn', nil, nil, 'shop is running low on dog food')
|
19
19
|
expected_log = {
|
20
|
+
"ecs" => {
|
21
|
+
"version" => '1.5.0'
|
22
|
+
},
|
20
23
|
"@timestamp" => '2020-05-11T15:01:01.000Z',
|
21
24
|
"service" => {
|
22
25
|
"name" => 'petshop'
|
data/test/logger_test.rb
CHANGED
@@ -49,6 +49,9 @@ describe Twiglet::Logger do
|
|
49
49
|
|
50
50
|
expected_log = {
|
51
51
|
message: 'Out of pets exception',
|
52
|
+
ecs: {
|
53
|
+
version: '1.5.0'
|
54
|
+
},
|
52
55
|
"@timestamp": '2020-05-11T15:01:01.000Z',
|
53
56
|
service: {
|
54
57
|
name: 'petshop'
|
@@ -136,10 +139,10 @@ describe Twiglet::Logger do
|
|
136
139
|
@logger.info({message: 'there'})
|
137
140
|
|
138
141
|
expected_output =
|
139
|
-
'{"@timestamp":"2020-05-11T15:01:01.000Z",'\
|
142
|
+
'{"ecs":{"version":"1.5.0"},"@timestamp":"2020-05-11T15:01:01.000Z",'\
|
140
143
|
'"service":{"name":"petshop"},"log":{"level":"debug"},"message":"hi"}'\
|
141
144
|
"\n"\
|
142
|
-
'{"@timestamp":"2020-05-11T15:01:01.000Z",'\
|
145
|
+
'{"ecs":{"version":"1.5.0"},"@timestamp":"2020-05-11T15:01:01.000Z",'\
|
143
146
|
'"service":{"name":"petshop"},"log":{"level":"info"},"message":"there"}'\
|
144
147
|
"\n"\
|
145
148
|
|
@@ -251,6 +254,9 @@ describe Twiglet::Logger do
|
|
251
254
|
|
252
255
|
expected_log = {
|
253
256
|
message: 'Out of pets exception',
|
257
|
+
ecs: {
|
258
|
+
version: '1.5.0'
|
259
|
+
},
|
254
260
|
"@timestamp": '2020-05-11T15:01:01.000Z',
|
255
261
|
service: {
|
256
262
|
name: 'petshop'
|
@@ -305,6 +311,10 @@ describe Twiglet::Logger do
|
|
305
311
|
assert_equal args[:level], @logger.level
|
306
312
|
end
|
307
313
|
end
|
314
|
+
|
315
|
+
it 'initializes the logger with the provided level' do
|
316
|
+
assert_equal Logger::WARN, Twiglet::Logger.new('petshop', level: :warn).level
|
317
|
+
end
|
308
318
|
end
|
309
319
|
|
310
320
|
private
|
data/twiglet.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twiglet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simply Business
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Like a log, only smaller.
|
14
14
|
email:
|
@@ -18,6 +18,7 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- ".github/CODEOWNERS"
|
21
|
+
- ".github/workflows/gem-publish.yml"
|
21
22
|
- ".github/workflows/ruby.yml"
|
22
23
|
- ".gitignore"
|
23
24
|
- ".rubocop.yml"
|
@@ -49,14 +50,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
49
50
|
requirements:
|
50
51
|
- - ">="
|
51
52
|
- !ruby/object:Gem::Version
|
52
|
-
version: '2.
|
53
|
+
version: '2.5'
|
53
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
55
|
requirements:
|
55
56
|
- - ">="
|
56
57
|
- !ruby/object:Gem::Version
|
57
58
|
version: '0'
|
58
59
|
requirements: []
|
59
|
-
rubygems_version: 3.
|
60
|
+
rubygems_version: 3.0.3
|
60
61
|
signing_key:
|
61
62
|
specification_version: 4
|
62
63
|
summary: Twiglet
|