twiglet 2.2.2 → 2.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9bd7e1ea9d6464abb4dcb96e8d2679ce6c82ebc289c55cb5989d8f8f657f065f
4
- data.tar.gz: 2b2d8e963cf250c0b746dd9d56c40368e31f67b1deaf6cd63c9dee9a731ce804
3
+ metadata.gz: b6b403959c8c42d8942d17af72a53419a68b8a90c0a805fbdec6703aa4e86d95
4
+ data.tar.gz: 7c99b71016b8f41ab0d82cfedcb376dd5704c77e1bdb7a00a99f48a89d1b2666
5
5
  SHA512:
6
- metadata.gz: 8277fd64f609bb4edbf6c95e0f97dc56784a1ea63415c1b261dd9649a69fd6cfee54abbb0c91dfb2232f78f0a14b9c539592d4ca58d57d566350f2a0dbceb648
7
- data.tar.gz: e9daae207235db6582162e7d2682cf69ea59e5dc09796b7d804bed6f31775ff07ceaff4b38518dd7c6d6a1ec40759c20dadcbebd388417187bcccb66c09fe793
6
+ metadata.gz: e22959d3b8796813b6f4b789ae00cf8629b83b14b31a4f525babc3718d7462c93e961391f3322c39a15bd26d08a38194cd1dd6d025d5c4871ada864be4e52c5b
7
+ data.tar.gz: bcf49062251a7b68b20ef559c124e04928593fc5a004ad21cbfd3262a716f382bcc3b462ca338bfd628796e5c40d14bf4c543d430f4e9d7c542a6201a7639f2b
@@ -1,3 +1,4 @@
1
1
  # Add your project owners info here
2
2
  # More information: https://help.github.com/articles/about-codeowners/
3
- * @simplybusiness/application-tooling
3
+ * @simplybusiness/silversmiths
4
+
@@ -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}}
@@ -13,7 +13,7 @@ jobs:
13
13
 
14
14
  strategy:
15
15
  matrix:
16
- ruby-version: [2.6, 2.7]
16
+ ruby-version: [2.5, 2.6, 2.7]
17
17
 
18
18
  steps:
19
19
  - uses: actions/checkout@v2
@@ -2,7 +2,7 @@ inherit_gem:
2
2
  simplycop: .simplycop.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.6
5
+ TargetRubyVersion: 2.5
6
6
  Rails:
7
7
  Enabled: false
8
8
  Documentation:
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
- Lastly, you can provide another optional keyword argument called `now`, which should be a function returning a `Time` string in ISO8601 format.
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
 
@@ -50,6 +50,9 @@ module Twiglet
50
50
 
51
51
  def log_message(level, message:)
52
52
  base_message = {
53
+ ecs: {
54
+ version: '1.5.0'
55
+ },
53
56
  "@timestamp": @now.call.iso8601(3),
54
57
  service: {
55
58
  name: @service_name
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Twiglet
4
- VERSION = '2.2.2'
4
+ VERSION = '2.3.6'
5
5
  end
@@ -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'
@@ -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
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = `git ls-files -- {test}/*`.split("\n")
19
19
 
20
20
  gem.require_paths = ['lib']
21
- gem.required_ruby_version = '>= 2.6'
21
+ gem.required_ruby_version = '>= 2.5'
22
22
 
23
23
  gem.license = 'Copyright SimplyBusiness'
24
24
  end
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.2.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-06-25 00:00:00.000000000 Z
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.6'
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.1.2
60
+ rubygems_version: 3.0.3
60
61
  signing_key:
61
62
  specification_version: 4
62
63
  summary: Twiglet