legion-settings 1.3.20 → 1.3.22

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: beeec634e807f88a6a10a9076a258efedc233d5cfe0412be24d96f01f2b9be35
4
- data.tar.gz: be84692b4242373941f10ee92dd0ed86df689d805283a6cd4e14879f7cd2a907
3
+ metadata.gz: 0e71ebdb5aa34fb51091d1c93fd14f23d090dfea2d8565945b62769c9d829287
4
+ data.tar.gz: 8a1f6bb8e73a46437562c47ffe9a9b396cc498eb68fcf876f9f660a3a98852b6
5
5
  SHA512:
6
- metadata.gz: 7f9f4ed4728098aeeb92e1925d3465e89d05d30d8ee01ae030fd1424b483d7c31b67f423659b63e7f44bd01dabc28aad1906db8148c3576ebacf73d2667491bd
7
- data.tar.gz: 247ed6734058a5ef16cd76ab37e7e620b8794d4fa60d6b7d561f616eef1030a1b461f71c65a987f1cc5223387df45e0eaf54105ec16ea9529355e772a9d3e930
6
+ metadata.gz: 1bea85658e1fe7556accbccc4ce7288d278aa3e18a461d45455ab00e117b4caa2d00736639b755619cb2a1a75ffc3382c2f0d732c4be40da2d3af0a614fc1f72
7
+ data.tar.gz: 16dac89ba37ef95d93318af918e56295488cfec31cb93f79276b66d32b29aa700d07de93992db6ca10342b81790fd2ea436904bb43f59dd4615a0a8b0e9d435b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Legion::Settings Changelog
2
2
 
3
+ ## [1.3.22] - 2026-03-27
4
+
5
+ ### Added
6
+ - Specs for `logging_defaults` covering all structured fields including `trace` and `transport.*` sub-keys
7
+
8
+ ### Changed
9
+ - README updated with version badge (1.3.22) and Logging Defaults section documenting `transport` sub-key
10
+
11
+ ## [1.3.21] - 2026-03-27
12
+
13
+ ### Changed
14
+ - Replace `logging` defaults (`location`, `backtrace_logging`) with structured fields: `format`, `log_file`, `log_stdout`, `async`, `include_pid`, and `transport` sub-key for forwarding flags
15
+ - Extract `logging_defaults` helper method to keep `default_settings` within method length limit
16
+
17
+ ### Fixed
18
+ - Prefer RFC-1918 private addresses over CGNAT (100.64.0.0/10) in client IP detection
19
+
3
20
  ## [1.3.20] - 2026-03-27
4
21
 
5
22
  ### Fixed
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Configuration management module for the [LegionIO](https://github.com/LegionIO/LegionIO) framework. Loads settings from JSON files, directories, and environment variables. Provides a unified `Legion::Settings[:key]` accessor used by all other Legion gems.
4
4
 
5
- **Version**: 1.3.19
5
+ **Version**: 1.3.22
6
6
 
7
7
  ## Installation
8
8
 
@@ -79,6 +79,31 @@ Legion::Settings.validate! # raises ValidationError if any settings are invalid
79
79
  # validate! will warn to $stderr (or Legion::Logging) instead of raising
80
80
  ```
81
81
 
82
+ ### Logging Defaults
83
+
84
+ The `logging` key includes a `transport` sub-section (new in 1.3.22) that controls whether log events are forwarded over the message bus:
85
+
86
+ ```json
87
+ {
88
+ "logging": {
89
+ "level": "info",
90
+ "format": "text",
91
+ "log_file": null,
92
+ "log_stdout": true,
93
+ "trace": true,
94
+ "async": true,
95
+ "include_pid": false,
96
+ "transport": {
97
+ "enabled": false,
98
+ "forward_logs": true,
99
+ "forward_exceptions": true
100
+ }
101
+ }
102
+ }
103
+ ```
104
+
105
+ When `transport.enabled` is `true`, log events and unhandled exceptions are published to the AMQP bus so a central log consumer can aggregate them. Disabled by default to avoid a dependency on `legion-transport` at boot.
106
+
82
107
  ## Requirements
83
108
 
84
109
  - Ruby >= 3.4
@@ -58,6 +58,23 @@ module Legion
58
58
  }
59
59
  end
60
60
 
61
+ def logging_defaults
62
+ {
63
+ level: 'info',
64
+ format: 'text',
65
+ log_file: nil,
66
+ log_stdout: true,
67
+ trace: true,
68
+ async: true,
69
+ include_pid: false,
70
+ transport: {
71
+ enabled: false,
72
+ forward_logs: true,
73
+ forward_exceptions: true
74
+ }
75
+ }
76
+ end
77
+
61
78
  def default_settings
62
79
  {
63
80
  client: client_defaults,
@@ -94,12 +111,7 @@ module Legion
94
111
  default_extension_settings: {
95
112
  logger: { level: 'info', trace: false, extended: false }
96
113
  },
97
- logging: {
98
- level: 'info',
99
- location: 'stdout',
100
- trace: true,
101
- backtrace_logging: true
102
- },
114
+ logging: logging_defaults,
103
115
  transport: { connected: false },
104
116
  data: { connected: false },
105
117
  role: { profile: nil, extensions: [] },
@@ -384,14 +396,20 @@ module Legion
384
396
  end
385
397
 
386
398
  def system_address
387
- Socket.ip_address_list.find do |address|
388
- address.ipv4? && !address.ipv4_loopback?
389
- end.ip_address
399
+ addresses = Socket.ip_address_list.select { |a| a.ipv4? && !a.ipv4_loopback? }
400
+ preferred = addresses.find { |a| rfc1918?(a.ip_address) }
401
+ (preferred || addresses.first)&.ip_address || 'unknown'
390
402
  rescue StandardError => e
391
403
  Legion::Logging.debug("Legion::Settings::Loader#system_address failed: #{e.message}") if defined?(Legion::Logging)
392
404
  'unknown'
393
405
  end
394
406
 
407
+ def rfc1918?(ip)
408
+ ip.start_with?('10.') ||
409
+ ip.match?(/\A172\.(1[6-9]|2\d|3[01])\./) ||
410
+ ip.start_with?('192.168.')
411
+ end
412
+
395
413
  def log_info(message)
396
414
  defined?(Legion::Logging) ? Legion::Logging.info(message) : $stdout.puts(message)
397
415
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module Settings
5
- VERSION = '1.3.20'
5
+ VERSION = '1.3.22'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion-settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.20
4
+ version: 1.3.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity