twiglet 2.2.1 → 2.3.5

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: 3cb9302ac1ae427b94de457a976ace7c30d30b875676f43e91b4e206056cedf9
4
- data.tar.gz: e436939ff209613f1a4f0c64c33f06a0cb3dcf36c9faa20b25bfc8c829946a26
3
+ metadata.gz: 7d22277c768790e3abfc51413438a55db70d811e86d30b8116781acd06aac938
4
+ data.tar.gz: '0017814848a2ebde3254c51f18771271c1c17d8834d1e03c9c7ff7c620e70349'
5
5
  SHA512:
6
- metadata.gz: 06f15914e02513b777e473c6472186f1d189dae59df2e8e59a5f00efad3d7a45d4cf053b96e862c0b9337b70c2c672de12fe73d9e766ceaa047d483005f5000b
7
- data.tar.gz: 35fbe15d0b18895fdb5443e2493d212c66989fea77eea204b2cb900535da78133e001c638981e856deacca3c905427222fa2a7073f895c1b26dbb270b63397c8
6
+ metadata.gz: 833ee6bc382e10b7203041e532244d6a5582913afe56ce62170fba00f9d442e8fb70aeef294e826a7f9874f53b0f73d7801df50179d85069ac53d67928ef7b5b
7
+ data.tar.gz: 590bb2ba1b31b8e6eef8f6d81bab98fc3bcf34210f5e6b6acffd46350f3e8ba7679bbbb2e332d516f742af96dc4f1dc54882d20b83851699734f523558fac059
@@ -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
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  *.gem
2
+ Gemfile.lock
2
3
  *.rbc
3
4
  /.config
4
5
  /coverage/
@@ -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
 
@@ -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.1'
4
+ VERSION = '2.3.5'
5
5
  end
@@ -136,9 +136,11 @@ describe Twiglet::Logger do
136
136
  @logger.info({message: 'there'})
137
137
 
138
138
  expected_output =
139
- '{"@timestamp":"2020-05-11T15:01:01.000Z","service":{"name":"petshop"},"log":{"level":"debug"},"message":"hi"}'\
139
+ '{"@timestamp":"2020-05-11T15:01:01.000Z",'\
140
+ '"service":{"name":"petshop"},"log":{"level":"debug"},"message":"hi"}'\
140
141
  "\n"\
141
- '{"@timestamp":"2020-05-11T15:01:01.000Z","service":{"name":"petshop"},"log":{"level":"info"},"message":"there"}'\
142
+ '{"@timestamp":"2020-05-11T15:01:01.000Z",'\
143
+ '"service":{"name":"petshop"},"log":{"level":"info"},"message":"there"}'\
142
144
  "\n"\
143
145
 
144
146
  assert_equal expected_output, @buffer.string
@@ -303,6 +305,10 @@ describe Twiglet::Logger do
303
305
  assert_equal args[:level], @logger.level
304
306
  end
305
307
  end
308
+
309
+ it 'initializes the logger with the provided level' do
310
+ assert_equal Logger::WARN, Twiglet::Logger.new('petshop', level: :warn).level
311
+ end
306
312
  end
307
313
 
308
314
  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.1
4
+ version: 2.3.5
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-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Like a log, only smaller.
14
14
  email:
@@ -18,13 +18,13 @@ 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"
24
25
  - ".ruby-version"
25
26
  - CODE_OF_CONDUCT.md
26
27
  - Gemfile
27
- - Gemfile.lock
28
28
  - LICENSE
29
29
  - RATIONALE.md
30
30
  - README.md
@@ -50,14 +50,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '2.6'
53
+ version: '2.5'
54
54
  required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  requirements:
56
56
  - - ">="
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
59
  requirements: []
60
- rubygems_version: 3.1.2
60
+ rubygems_version: 3.0.3
61
61
  signing_key:
62
62
  specification_version: 4
63
63
  summary: Twiglet
@@ -1,62 +0,0 @@
1
- GIT
2
- remote: https://github.com/simplybusiness/simplycop.git
3
- revision: 02b417277e3ff9eeab34d6b7c30a95a17d876731
4
- specs:
5
- simplycop (0.5.4)
6
- rubocop (~> 0.80.0)
7
- rubocop-rails
8
- rubocop-rspec
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- activesupport (6.0.3.1)
14
- concurrent-ruby (~> 1.0, >= 1.0.2)
15
- i18n (>= 0.7, < 2)
16
- minitest (~> 5.1)
17
- tzinfo (~> 1.1)
18
- zeitwerk (~> 2.2, >= 2.2.2)
19
- ast (2.4.0)
20
- concurrent-ruby (1.1.6)
21
- i18n (1.8.2)
22
- concurrent-ruby (~> 1.0)
23
- jaro_winkler (1.5.4)
24
- minitest (5.14.0)
25
- parallel (1.19.1)
26
- parser (2.7.1.3)
27
- ast (~> 2.4.0)
28
- rack (2.2.3)
29
- rainbow (3.0.0)
30
- rake (13.0.1)
31
- rexml (3.2.4)
32
- rubocop (0.80.1)
33
- jaro_winkler (~> 1.5.1)
34
- parallel (~> 1.10)
35
- parser (>= 2.7.0.1)
36
- rainbow (>= 2.2.2, < 4.0)
37
- rexml
38
- ruby-progressbar (~> 1.7)
39
- unicode-display_width (>= 1.4.0, < 1.7)
40
- rubocop-rails (2.5.2)
41
- activesupport
42
- rack (>= 1.1)
43
- rubocop (>= 0.72.0)
44
- rubocop-rspec (1.39.0)
45
- rubocop (>= 0.68.1)
46
- ruby-progressbar (1.10.1)
47
- thread_safe (0.3.6)
48
- tzinfo (1.2.7)
49
- thread_safe (~> 0.1)
50
- unicode-display_width (1.6.1)
51
- zeitwerk (2.3.0)
52
-
53
- PLATFORMS
54
- ruby
55
-
56
- DEPENDENCIES
57
- minitest
58
- rake
59
- simplycop!
60
-
61
- BUNDLED WITH
62
- 2.1.4