legion-logging 1.3.2 → 1.3.4

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: d2284e01a8b8c373629f5c7aaf8a648c06dd706a4a6d516cdc27a80ce63eb631
4
- data.tar.gz: 6398739b5097e7cc59d2683e70eefbec5a305e0f85707a40f62ebcbd147176df
3
+ metadata.gz: ac6e65a10ce7708585f78114b5ee2d18303430e0d70b9039620f819a7de14325
4
+ data.tar.gz: fbf159026929b5d15668cd68aa5b0533f05d32ed67587389ade09a97bddc910c
5
5
  SHA512:
6
- metadata.gz: bd5bbabd136edfc7079db6e7ff1a804839a9513e135f2594b0cfc43a17573d9aa0cf30f0d9a3c47e4e0fabf91cefb3772394076e98767b44adee9edaa940384f
7
- data.tar.gz: a2fec71358fc96100f3fddae8002b762aad9381c5a030eec3c60b6d282f081204e6699d8f34a8a19901c104ae49d3ea708eca32bcccc793b265c50faad328c16
6
+ metadata.gz: 0a94512fdad36ed375ee678cc64bf7473496418cd3f25d560286d83f0db5af32c86eb262d489725bfc70b6e9e44724d197b8a85b4497073da6932f8a312c0682
7
+ data.tar.gz: f146a912510f6b0eba2e3b28bc86952330e8d31caaee509869ee116fa12c60a21c599af4c882c44524d674a0ccc1320eea5ab6a5f13afd9c770c5c0d5de35dd5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Legion::Logging Changelog
2
2
 
3
+ ## [1.3.4] - 2026-03-24
4
+
5
+ ### Fixed
6
+ - `EventBuilder#derive_lex_source` no longer blindly prepends `lex-` to all source names (was causing `add_gem_info` to fail for core gems like `legion-data` with `Could not find 'lex-data'`)
7
+ - `EventBuilder#add_gem_info` now tries raw name, `lex-<name>`, and `legion-<name>` prefixes when resolving gem specs (extracted to `resolve_gem_spec` method)
8
+
9
+ ## [1.3.3] - 2026-03-24
10
+
11
+ ### Changed
12
+ - Reindex docs: update CLAUDE.md and README with AsyncWriter and Helper module docs
13
+
3
14
  ## [1.3.2] - 2026-03-22
4
15
 
5
16
  ### Added
data/CLAUDE.md CHANGED
@@ -8,7 +8,7 @@
8
8
  Ruby logging class for the LegionIO framework. Provides colorized console output via Rainbow, structured JSON logging (`format: :json`), and a consistent logging interface across all Legion gems and extensions.
9
9
 
10
10
  **GitHub**: https://github.com/LegionIO/legion-logging
11
- **Version**: 1.2.5
11
+ **Version**: 1.3.2
12
12
  **License**: Apache-2.0
13
13
 
14
14
  ## Architecture
@@ -16,9 +16,11 @@ Ruby logging class for the LegionIO framework. Provides colorized console output
16
16
  ```
17
17
  Legion::Logging (singleton module)
18
18
  ├── Methods # Log level methods: debug, info, warn, error, fatal, unknown
19
- ├── Builder # Output destination (stdout/file), log level, formatter
19
+ ├── Builder # Output destination (stdout/file), log level, formatter, async: keyword
20
+ ├── AsyncWriter # Non-blocking SizedQueue-backed writer thread; fatal calls bypass queue
20
21
  ├── Hooks # Callback registry for fatal/error/warn events (on_fatal, on_error, on_warn)
21
22
  ├── EventBuilder # Structured event payload builder (caller, exception, lex, gem metadata)
23
+ ├── Helper # Injectable log mixin for LEX extensions (derives logger tags from segments/class)
22
24
  ├── Logger # Core logger configuration and setup
23
25
  ├── MultiIO # Write to multiple destinations simultaneously
24
26
  ├── SIEMExporter # PHI-redacting SIEM export (Splunk HEC, ELK/OpenSearch)
@@ -31,13 +33,15 @@ Legion::Logging (singleton module)
31
33
 
32
34
  - **Singleton Module**: `Legion::Logging` uses `class << self` - called directly: `Legion::Logging.info("msg")`
33
35
  - **Rainbow Colorization**: Console output uses Rainbow gem for colored terminal output
34
- - **Setup Method**: `Legion::Logging.setup(log_file:, level:)` configures output destination and level
36
+ - **Setup Method**: `Legion::Logging.setup(log_file:, level:, async: true)` configures output destination, level, and async mode
37
+ - **Async by Default**: `setup` enables async logging — calls return immediately. Fatal calls always bypass the queue. `stop_async_writer` flushes and stops on shutdown. Buffer size configurable via `Legion::Settings.dig(:logging, :async, :buffer_size)` (default 10,000). Back-pressure: callers block when buffer is full.
35
38
  - **Structured JSON**: `format: :json` in settings outputs machine-parseable JSON log lines
36
39
  - **Shared Interface**: Same method signature (`info`, `warn`, `error`, etc.) across all Legion components
37
40
  - **MultiIO**: Splits writes to stdout and a log file simultaneously (used by Builder when `log_file` is set)
38
41
  - **SIEMExporter**: PHI redaction (SSN, phone, MRN, DOB patterns), `export_to_splunk` (HEC), `format_for_elk`
39
- - **Hook Callbacks**: `on_fatal`, `on_error`, `on_warn` register procs called after each log at those levels. Hooks are gated by `enable_hooks!`/`disable_hooks!`. Hook failures are silently rescued — never impact the logger.
42
+ - **Hook Callbacks**: `on_fatal`, `on_error`, `on_warn` register procs called after each log at those levels. Hooks are gated by `enable_hooks!`/`disable_hooks!`. Hook failures are silently rescued — never impact the logger. Hooks fire on the async writer thread; event context captured on caller thread.
40
43
  - **EventBuilder**: Builds structured event hashes from log context (caller location, exception info, lex identity, gem metadata). All from in-memory data, zero IO.
44
+ - **Helper mixin**: `Legion::Logging::Helper` is injectable into LEX extensions. Derives logger tags from `segments`, `lex_filename`, or class name. Passes through `settings[:logger]` config when available.
41
45
 
42
46
  ## Dependencies
43
47
 
@@ -51,7 +55,9 @@ Legion::Logging (singleton module)
51
55
  |------|---------|
52
56
  | `lib/legion/logging.rb` | Module entry point |
53
57
  | `lib/legion/logging/methods.rb` | Log level methods |
54
- | `lib/legion/logging/builder.rb` | Output config and formatter |
58
+ | `lib/legion/logging/builder.rb` | Output config and formatter (async: keyword) |
59
+ | `lib/legion/logging/async_writer.rb` | Non-blocking SizedQueue-backed writer thread with back-pressure |
60
+ | `lib/legion/logging/helper.rb` | Injectable log mixin for LEX extensions |
55
61
  | `lib/legion/logging/logger.rb` | Core logger setup |
56
62
  | `lib/legion/logging/multi_io.rb` | Multi-output IO (write to multiple destinations simultaneously) |
57
63
  | `lib/legion/logging/siem_exporter.rb` | PHI-redacting SIEM export helpers (Splunk HEC, ELK format) |
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Logging module for the [LegionIO](https://github.com/LegionIO/LegionIO) framework. Provides colorized console output via Rainbow, structured JSON logging, multi-output IO, and a consistent logging interface across all Legion gems and extensions.
4
4
 
5
- **Version**: 1.3.0
5
+ **Version**: 1.3.2
6
6
 
7
7
  ## Installation
8
8
 
@@ -79,6 +79,21 @@ Legion::Logging::SIEMExporter.format_for_elk(event, index: 'legion')
79
79
 
80
80
  PHI patterns redacted: SSN (`###-##-####`), phone (`###-###-####`), MRN (`XX#######`), DOB (`##/##/####`).
81
81
 
82
+ ### Helper Mixin
83
+
84
+ `Legion::Logging::Helper` is an injectable mixin for LEX extensions. It derives logger tags from `segments`, `lex_filename`, or class name automatically, and passes through `settings[:logger]` config when available. Allows LEX gems to use `legion-logging` directly without requiring the full LegionIO framework.
85
+
86
+ ```ruby
87
+ class MyRunner
88
+ include Legion::Logging::Helper
89
+
90
+ def run
91
+ log.info("starting")
92
+ log.debug("details")
93
+ end
94
+ end
95
+ ```
96
+
82
97
  ## Requirements
83
98
 
84
99
  - Ruby >= 3.4
@@ -29,9 +29,9 @@ module Legion
29
29
 
30
30
  def derive_lex_source(lex, lex_segments)
31
31
  if lex_segments.is_a?(Array) && !lex_segments.empty?
32
- "lex-#{lex_segments.join('-')}"
32
+ lex_segments.join('-')
33
33
  elsif lex && !lex.to_s.empty?
34
- "lex-#{lex}"
34
+ lex.to_s
35
35
  end
36
36
  end
37
37
 
@@ -71,7 +71,9 @@ module Legion
71
71
  def add_gem_info(event, lex_source)
72
72
  return unless lex_source
73
73
 
74
- spec = Gem::Specification.find_by_name(lex_source)
74
+ spec = resolve_gem_spec(lex_source)
75
+ return unless spec
76
+
75
77
  event[:gem] = {
76
78
  name: spec.name,
77
79
  version: spec.version.to_s,
@@ -79,8 +81,14 @@ module Legion
79
81
  homepage: spec.metadata['homepage_uri'] || spec.homepage,
80
82
  path: spec.full_gem_path
81
83
  }.compact
82
- rescue Gem::MissingSpecError, ArgumentError => e
83
- warn("Legion::Logging::EventBuilder#add_gem_info failed for #{lex_source}: #{e.message}")
84
+ end
85
+
86
+ def resolve_gem_spec(name)
87
+ [name, "lex-#{name}", "legion-#{name}"].each do |candidate|
88
+ return Gem::Specification.find_by_name(candidate)
89
+ rescue Gem::MissingSpecError
90
+ next
91
+ end
84
92
  nil
85
93
  end
86
94
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module Logging
5
- VERSION = '1.3.2'
5
+ VERSION = '1.3.4'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion-logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity