legion-logging 1.5.1 → 1.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46129a3dbab733493155c3883562e0b8f867959f9749b0ead2c55096eaaa91f0
4
- data.tar.gz: e5de12a36bdaa85ceca97cf8936312257ad607393b56fa3663ac0f827d850315
3
+ metadata.gz: 57e4eef04828ffa39cae5277822be4f2f5264d4010b05e724dbb179f0af5b771
4
+ data.tar.gz: 740663a6979cf6b5c5d90a12bc8c43e0fcd989b8d8253269d8a1f1bf9aff9d03
5
5
  SHA512:
6
- metadata.gz: cbedead38cab56af14b780484b110f6f9a8bb6fbc28934478f203d02dea738208fe9fbc63e3c7bdb8d8cc90a33b3328ba39e5059cff85a0ab8be7e83a7068c7f
7
- data.tar.gz: 337d49c5e424fc9cf487cec98295e4fd80a71da2882a5892c2b478d896cf05e52f6f10632719737df4072abbc555193c1475ae7b01d0e9f51d88ac5df3cc62fc
6
+ metadata.gz: c590642e775a8f6ed7f87f9b4525049033c3e3f42635ea2e460e5b4ddd89e646a97d8744b80755a82db340ba6e813d8e95e3a8b27ffc17a63f8f3aee99e5b5a6
7
+ data.tar.gz: b812f47d57057a466655f22ae1f3922b6326a22fd40297ce602850069092efaf20ff40a6689ecbfe22a7498429bb3266df70ec40efb69617d11da045695155bd
data/.gitignore CHANGED
@@ -9,7 +9,8 @@
9
9
  /tmp/
10
10
  /legion/.idea/
11
11
  /.idea/
12
+ *.gem
12
13
  *.key
13
14
  # rspec failure tracking
14
15
  .rspec_status
15
- legionio.key
16
+ legionio.key
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Legion::Logging Changelog
2
2
 
3
+ ## [1.5.2] - 2026-04-27
4
+
5
+ ### Changed
6
+ - Exception stdout/file log lines now include the full backtrace instead of truncating after 10 frames with a `... N more` suffix.
7
+
3
8
  ## [1.5.1] - 2026-04-08
4
9
 
5
10
  ### Added
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.5.0
5
+ **Version**: 1.5.2
6
6
 
7
7
  ## Installation
8
8
 
@@ -96,23 +96,46 @@ end
96
96
 
97
97
  ### Exception Logging
98
98
 
99
- `log_exception` provides a single call for complete structured exception events with component context:
99
+ `log_exception` provides a single call for complete exception logging with component context. It writes a human-readable exception line through the configured logger and publishes a structured exception event when an `exception_writer` is configured.
100
100
 
101
101
  ```ruby
102
- Legion::Logging.log_exception(exception,
103
- handled: true,
104
- component_type: :runner,
105
- lex: 'my_extension',
106
- task_id: 'abc-123')
102
+ begin
103
+ runner.call
104
+ rescue StandardError => e
105
+ Legion::Logging.log_exception(
106
+ e,
107
+ handled: true,
108
+ component_type: :runner,
109
+ lex: 'my_extension',
110
+ task_id: 'abc-123'
111
+ )
112
+ end
107
113
  ```
108
114
 
115
+ The synchronous log line includes the full Ruby backtrace. Legion does not truncate it to a fixed frame count or replace the tail with `... N more`, because the missing frames are often the useful part of production failures.
116
+
117
+ Structured exception events include:
118
+
119
+ - exception class and message
120
+ - full backtrace array
121
+ - caller file, line, and function where available
122
+ - log level and handled/unhandled status
123
+ - component type, lex name, gem name, version, and source path metadata
124
+ - task and thread context
125
+ - stable error fingerprint for deduplication
126
+
109
127
  ### Writer Lambdas
110
128
 
111
129
  `log_writer` and `exception_writer` are pluggable lambda slots that replace the old Hooks system. Assign them to forward events to external systems:
112
130
 
113
131
  ```ruby
114
- Legion::Logging.exception_writer = ->(payload, routing_key:, headers:, properties:) { publish_to_amqp(payload) }
115
- Legion::Logging.log_writer = ->(context, routing_key:) { publish_log(context) }
132
+ Legion::Logging.exception_writer = lambda do |payload, routing_key:, headers:, properties:|
133
+ publish_to_amqp(payload, routing_key:, headers:, properties:)
134
+ end
135
+
136
+ Legion::Logging.log_writer = lambda do |context, routing_key:|
137
+ publish_log(context, routing_key:)
138
+ end
116
139
  ```
117
140
 
118
141
  ### EventBuilder
@@ -121,7 +144,9 @@ Legion::Logging.log_writer = ->(context, routing_key:) { publish_log(context) }
121
144
 
122
145
  ### Redactor
123
146
 
124
- `Legion::Logging::Redactor` redacts PII/PHI patterns (SSN, phone, MRN, DOB) plus Vault tokens, JWTs, bearer tokens, and lease IDs from log messages. Redaction is opt-in: load the module (for example via `require 'legion/logging/redactor'`) and enable it with `logging.redaction.enabled: true`. When loaded and enabled, it is wired into all log methods in the write path.
147
+ `Legion::Logging::Redactor` redacts PII/PHI patterns (SSN, email, phone, MRN, DOB, credit card) plus Vault tokens, JWTs, bearer tokens, `vault://` URIs, `lease://` URIs, and lease IDs from log messages. Redaction is opt-in for text log lines: load the module (for example via `require 'legion/logging/redactor'`) and enable it with `logging.redaction.enabled: true`. When loaded and enabled, it is wired into all log methods in the write path.
148
+
149
+ Structured exception events are redacted before publishing when the redactor is loaded. This includes event identity fields such as `user`, so email-shaped local usernames are not forwarded raw.
125
150
 
126
151
  ## Requirements
127
152
 
@@ -32,7 +32,6 @@ module Legion
32
32
  'middleware' => :middleware
33
33
  }.freeze
34
34
 
35
- EXCEPTION_BACKTRACE_LIMIT = 10
36
35
  EXCEPTION_PRIORITY = { warn: 0, error: 5, fatal: 9 }.freeze
37
36
  EXCEPTION_COLORS = {
38
37
  fatal: :darkred,
@@ -489,11 +488,7 @@ module Legion
489
488
  lines << " #{context_line}" unless context_line.empty?
490
489
 
491
490
  bt = exception.backtrace
492
- if bt&.any?
493
- bt.first(EXCEPTION_BACKTRACE_LIMIT).each { |frame| lines << " #{frame}" }
494
- remaining = bt.length - EXCEPTION_BACKTRACE_LIMIT
495
- lines << " ... #{remaining} more" if remaining.positive?
496
- end
491
+ bt.each { |frame| lines << " #{frame}" } if bt&.any?
497
492
 
498
493
  lines.join("\n")
499
494
  end
@@ -109,11 +109,8 @@ module Legion
109
109
  msg = maybe_redact(msg)
110
110
  bt = Array(exception.backtrace)
111
111
  if bt.any?
112
- limit = defined?(Legion::Logging::Helper::EXCEPTION_BACKTRACE_LIMIT) ? Legion::Logging::Helper::EXCEPTION_BACKTRACE_LIMIT : 10
113
112
  lines = ["#{exception.class}: #{msg}"]
114
- bt.first(limit).each { |frame| lines << " #{frame}" }
115
- remaining = bt.length - limit
116
- lines << " ... #{remaining} more" if remaining.positive?
113
+ bt.each { |frame| lines << " #{frame}" }
117
114
  msg = lines.join("\n")
118
115
  end
119
116
  log.public_send(level, msg) if respond_to?(:log) && log.respond_to?(level)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module Logging
5
- VERSION = '1.5.1'
5
+ VERSION = '1.5.2'
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.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity