dvla-herodotus 2.3.0 → 2.3.2
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/.gitignore +2 -1
- data/CHANGELOG.md +6 -0
- data/README.md +16 -0
- data/lib/dvla/herodotus/herodotus_logger.rb +10 -0
- data/lib/dvla/herodotus/version.rb +1 -1
- data/lib/dvla/herodotus.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ef5bb32768faf3905e84a5aa343b4905d490dfda82fd8e350e985d10387a439
|
|
4
|
+
data.tar.gz: bf979b603e8cb1a2cfca96bb1ff837a313e0263910eef4c08b8902920bb1a462
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62168b57257f7d376c0ca807a61822cceeb612a8eb2744e6b29755ead02b80e934317eaa56667c267407d8131324261e69a41c6e75b0d78c1f1b3e0ef126bc67
|
|
7
|
+
data.tar.gz: b416dfe7ca587ef5ad83b04a748b7966b3c0da1336164f7cbea36330298ed8a5acc23e00ffda7b7e05075de595fee35116d6a58a4806e88bfec89e71130d2742
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
## [2.3.2] - 2025-12-23
|
|
5
|
+
- Add 'spawn_child_logger' method to allow other processes to inherit the current logger's configuration
|
|
6
|
+
|
|
7
|
+
## [2.3.1] - 2025-11-21
|
|
8
|
+
- Fixed issue with output_path in create_logger, will now make a directory if it did not exist
|
|
9
|
+
|
|
4
10
|
## [2.3.0] - 2025-10-05
|
|
5
11
|
- Config block can now accept prefix colour options. Can be applied to the whole prefix or configure individual components.
|
|
6
12
|
|
data/README.md
CHANGED
|
@@ -102,6 +102,22 @@ You can call `new_scenario` with the identifier just before each scenario to cre
|
|
|
102
102
|
logger.new_scenario('Scenario Id')
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
### spawn_child_logger method
|
|
106
|
+
You can call `spawn_child_logger` with a new system_name which will retain the current logger's config.
|
|
107
|
+
This enables you to pass loggers to other tools and maintain the same colourisation and output_path.
|
|
108
|
+
|
|
109
|
+
```ruby
|
|
110
|
+
config = DVLA::Herodotus.config do |configuration|
|
|
111
|
+
configuration.display_pid = false
|
|
112
|
+
configuration.main = true
|
|
113
|
+
configuration.prefix_colour = {
|
|
114
|
+
overall: %w[blue bold],
|
|
115
|
+
}
|
|
116
|
+
end
|
|
117
|
+
LOG = DVLA::Herodotus.logger('<system-name>', config:, output_path: -> { "log.txt" })
|
|
118
|
+
NewTool.new(logger: LOG.spawn_child_logger(system_name: 'new gem'))
|
|
119
|
+
```
|
|
120
|
+
|
|
105
121
|
---
|
|
106
122
|
### Strings
|
|
107
123
|
|
|
@@ -58,6 +58,16 @@ module DVLA
|
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
+
# Creates a new logger with a different system name but inherits config and output path
|
|
62
|
+
def spawn_child_logger(system_name:)
|
|
63
|
+
config = DVLA::Herodotus.config do |c|
|
|
64
|
+
c.display_pid = @display_pid
|
|
65
|
+
c.main = false
|
|
66
|
+
c.prefix_colour = @prefix_colour
|
|
67
|
+
end
|
|
68
|
+
HerodotusLogger.new(system_name, @logdev.dev, config: config)
|
|
69
|
+
end
|
|
70
|
+
|
|
61
71
|
%i[debug info warn error fatal].each do |log_level|
|
|
62
72
|
define_method log_level do |progname = nil, &block|
|
|
63
73
|
set_proc_writer_scenario
|
data/lib/dvla/herodotus.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'logger'
|
|
2
|
+
require 'fileutils'
|
|
2
3
|
require_relative 'herodotus/herodotus_logger'
|
|
3
4
|
require_relative 'herodotus/multi_writer'
|
|
4
5
|
require_relative 'herodotus/proc_writer'
|
|
@@ -25,9 +26,11 @@ module DVLA
|
|
|
25
26
|
private_class_method def self.create_logger(system_name, config, output_path)
|
|
26
27
|
if output_path
|
|
27
28
|
if output_path.is_a? String
|
|
29
|
+
ensure_directory_exists(output_path: output_path)
|
|
28
30
|
output_file = File.open(output_path, 'a')
|
|
29
31
|
return HerodotusLogger.new(system_name, MultiWriter.new(output_file, $stdout), config: config)
|
|
30
32
|
elsif output_path.is_a? Proc
|
|
33
|
+
ensure_directory_exists(output_path: output_path.call)
|
|
31
34
|
proc_writer = ProcWriter.new(output_path)
|
|
32
35
|
return HerodotusLogger.new(system_name, MultiWriter.new(proc_writer, $stdout), config: config)
|
|
33
36
|
else
|
|
@@ -36,5 +39,12 @@ module DVLA
|
|
|
36
39
|
end
|
|
37
40
|
HerodotusLogger.new(system_name, $stdout, config: config)
|
|
38
41
|
end
|
|
42
|
+
|
|
43
|
+
private_class_method def self.ensure_directory_exists(output_path:)
|
|
44
|
+
directory = File.split(output_path).first
|
|
45
|
+
unless File.directory?(directory)
|
|
46
|
+
FileUtils.mkdir_p(directory)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
39
49
|
end
|
|
40
50
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dvla-herodotus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.3.
|
|
4
|
+
version: 2.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Driver and Vehicle Licensing Agency (DVLA)
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2026-01-22 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: dvla-lint
|