dvla-herodotus 1.0.0 → 1.1.0

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
  SHA256:
3
- metadata.gz: def32028eabb2e8b3320cd06f229d9b882c1a586dbf8b7cdeef6e69f4998fd9a
4
- data.tar.gz: 0f9aadf85396b5585db242196f0f5562b9af755ac69901c967fd537a824e5f7c
3
+ metadata.gz: 44f213f7b551a5dedbe3caaca66eafc7471b539eac4ec2271b3687e0be26d934
4
+ data.tar.gz: 21b3bf02e8ddf43b4eb8accadd47a607a25013943869e8b3b03587e3157568fd
5
5
  SHA512:
6
- metadata.gz: 9bf48e9d451a7f9f42fdc44f6af3dcb1844ce36ac82cafc6c8bec0596bda2159d14ba2b9b6aad6ebfaf54b220e53bd66e762e36df68a938c4c6a04b95ccdd1c8
7
- data.tar.gz: d6566b93fc7289175e97b989c4948040be0152eae81997920912c722f26d5d34c24286b01c37ac49b961d28637bface0883b14867f2069db598665ede9affe7b
6
+ metadata.gz: 22fed7800687b7acaf63195afd9c93fcab67914b6456ad8928f2cd4345b256f92ff91b7c22239e2c9bb65853b1dd976f6835647f25431c42e1335af8c541c6e3
7
+ data.tar.gz: 72177da622343e613def838c5e195e0da15c8fccaf8dadcb3bf84ce164eab7b1c481e45c898ca5b7ad99004634ad4e58bd339a6788aca1780786121852ada22b
@@ -0,0 +1,48 @@
1
+ name: Ruby Gem Publish
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ ruby-version: [ '3.0', '3.1', '3.2' ]
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby-version }}
20
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
21
+ - name: Run tests
22
+ run: bundle exec rspec
23
+
24
+ deploy:
25
+ needs: test
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ packages: write
29
+ contents: read
30
+
31
+ steps:
32
+ - uses: actions/checkout@v2
33
+ - name: Set up Ruby 3.0.1
34
+ uses: ruby/setup-ruby@v1
35
+ with:
36
+ ruby-version: 3.1.2
37
+ bundler-cache: true
38
+
39
+ - name: Publish to RubyGems
40
+ run: |
41
+ mkdir -p $HOME/.gem
42
+ touch $HOME/.gem/credentials
43
+ chmod 0600 $HOME/.gem/credentials
44
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
45
+ gem build *.gemspec
46
+ gem push *.gem
47
+ env:
48
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
@@ -0,0 +1,22 @@
1
+ name: Ruby Test
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [ "main" ]
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ ruby-version: [ '3.0', '3.1', '3.2' ]
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby-version }}
20
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
21
+ - name: Run tests
22
+ run: bundle exec rspec
@@ -8,3 +8,5 @@
8
8
  /dataSources.local.xml
9
9
 
10
10
  /.idea
11
+
12
+ Gemfile.lock
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 HM Government (Driver and Vehicle Licensing Agency)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -28,6 +28,12 @@ You can get a logger by calling the following once Herodotus is installed:
28
28
  logger = DVLA::Herodotus.logger
29
29
  ```
30
30
 
31
+ You can also provide the path to an output file, which will be logged to simultaneously with standard console logger
32
+
33
+ ```ruby
34
+ logger = DVLA::Herodotus.logger(output_path: 'logs.txt')
35
+ ```
36
+
31
37
  This is a standard Ruby logger, so anything that would work on a logger acquired the traditional way will also work here, however it is formatted such that all logs will be output in the following format:
32
38
 
33
39
  `[CurrentDate CurrentTime CorrelationId] Level : -- Message`
@@ -8,6 +8,9 @@ Gem::Specification.new do |spec|
8
8
 
9
9
  spec.summary = 'Provides a lightweight logger with a common format'
10
10
  spec.required_ruby_version = Gem::Requirement.new('>= 3')
11
+ spec.homepage = 'https://github.com/dvla/herodotus'
12
+
13
+ spec.license = 'MIT'
11
14
 
12
15
  # Specify which files should be added to the gem when it is released.
13
16
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -0,0 +1,19 @@
1
+ module DVLA
2
+ module Herodotus
3
+ class MultiWriter
4
+ def initialize(*targets)
5
+ @targets = *targets
6
+ end
7
+
8
+ def write(*args)
9
+ @targets.each { |t| t.write(*args) }
10
+ end
11
+
12
+ def close
13
+ @targets.each do |t|
14
+ t.close unless t.eql? $stdout
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  module DVLA
2
2
  module Herodotus
3
- VERSION = '1.0.0'.freeze
3
+ VERSION = '1.1.0'.freeze
4
4
  end
5
5
  end
@@ -1,6 +1,7 @@
1
1
  require 'logger'
2
- require_relative 'herodotus/string'
3
2
  require_relative 'herodotus/herodotus_logger'
3
+ require_relative 'herodotus/multi_writer'
4
+ require_relative 'herodotus/string'
4
5
 
5
6
  module DVLA
6
7
  module Herodotus
@@ -16,8 +17,8 @@ module DVLA
16
17
  @config || configure
17
18
  end
18
19
 
19
- def self.logger
20
- logger = HerodotusLogger.new($stdout)
20
+ def self.logger(output_path: nil)
21
+ logger = create_logger(output_path)
21
22
  logger.system_name = "#{config.system_name} " unless config.system_name.nil?
22
23
  logger.requires_pid = config.pid
23
24
  logger.merge = config.merge
@@ -25,5 +26,14 @@ module DVLA
25
26
  logger.merge_correlation_ids if config.merge
26
27
  logger
27
28
  end
29
+
30
+ private_class_method def self.create_logger(output_path)
31
+ if output_path
32
+ output_file = File.open(output_path, 'a+')
33
+ HerodotusLogger.new(MultiWriter.new(output_file, $stdout))
34
+ else
35
+ HerodotusLogger.new($stdout)
36
+ end
37
+ end
28
38
  end
29
39
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dvla-herodotus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Driver and Vehicle Licensing Agency (DVLA)
8
8
  - George Bell
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-05-17 00:00:00.000000000 Z
12
+ date: 2023-08-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -25,25 +25,30 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '3.8'
28
- description:
28
+ description:
29
29
  email:
30
30
  - george.bell.contractor@dvla.gov.uk
31
31
  executables: []
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
- - ".idea/.gitignore"
35
+ - ".github/workflows/gem-push.yml"
36
+ - ".github/workflows/gem-test.yml"
37
+ - ".gitignore"
36
38
  - Gemfile
39
+ - LICENSE
37
40
  - README.md
38
41
  - dvla-herodotus.gemspec
39
42
  - lib/dvla/herodotus.rb
40
43
  - lib/dvla/herodotus/herodotus_logger.rb
44
+ - lib/dvla/herodotus/multi_writer.rb
41
45
  - lib/dvla/herodotus/string.rb
42
46
  - lib/dvla/herodotus/version.rb
43
- homepage:
44
- licenses: []
47
+ homepage: https://github.com/dvla/herodotus
48
+ licenses:
49
+ - MIT
45
50
  metadata: {}
46
- post_install_message:
51
+ post_install_message:
47
52
  rdoc_options: []
48
53
  require_paths:
49
54
  - lib
@@ -59,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
64
  version: '0'
60
65
  requirements: []
61
66
  rubygems_version: 3.3.7
62
- signing_key:
67
+ signing_key:
63
68
  specification_version: 4
64
69
  summary: Provides a lightweight logger with a common format
65
70
  test_files: []