belt 0.5.1 → 0.5.3
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/CHANGELOG.md +23 -0
- data/lib/belt/cli/logs_command.rb +22 -4
- data/lib/belt/version.rb +1 -1
- data/lib/templates/module/main.tf.erb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2267465d1ad5fcc7e7e8b7d7c6be91919275a8bd6bc541c82c9751ac2265ab27
|
|
4
|
+
data.tar.gz: 12c71c5a5db0520f26ee6df68fbbbbd5403105cb9ab2c08da2719d6513a6269e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7716c4d8eebea928388accc998fb38f00ffedf9c5cd8585ef6e8540d2a524e5a139002d434b1a5644e3b656c394692438715b39e87d7e9682b05b948273a8213
|
|
7
|
+
data.tar.gz: 7259396f97e7e750c9b6f19092535deb3552e98a2d9af927f01a0bfef09352b0164ad9febf1de4572ca132ad82686d60f101c5b640a32013d88019395e0dd70a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.3
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **New apps now package `lambda/config/` into every Lambda.** The generated
|
|
8
|
+
`infrastructure/modules/app/main.tf` listed `lambda_shared_dirs` without `config`, so
|
|
9
|
+
`lambda/config/environment.rb` never reached `/var/task`. Handlers generated by
|
|
10
|
+
belt-pay (`pay_webhooks.rb`) and belt-messaging (`messaging_events.rb`) start with
|
|
11
|
+
`require_relative 'config/environment'`, so they crashed on init with
|
|
12
|
+
`cannot load such file -- /var/task/config/environment`. Existing apps: add `"config"`
|
|
13
|
+
to `lambda_shared_dirs` in `infrastructure/modules/app/main.tf` and redeploy.
|
|
14
|
+
|
|
15
|
+
## 0.5.2
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **`belt logs` now surfaces extra structured fields on each log line.** Any custom
|
|
20
|
+
keys passed to the structured logger (e.g. `sku`, `mode`, `user_id`) are rendered as
|
|
21
|
+
dim `key=value` pairs appended to ERROR, WARN, and generic leveled log lines. Keys
|
|
22
|
+
already shown elsewhere or too noisy to repeat (`level`, `message`, `timestamp`,
|
|
23
|
+
`request_id`, `action`, `backtrace`, etc.) are filtered out, and `nil` values are
|
|
24
|
+
skipped. Non-string values are JSON-encoded so structured context stays readable.
|
|
25
|
+
|
|
3
26
|
## 0.5.0
|
|
4
27
|
|
|
5
28
|
### Added
|
|
@@ -62,6 +62,12 @@ module Belt
|
|
|
62
62
|
USAGE
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
+
# Structured log keys already rendered elsewhere or too noisy to repeat per line.
|
|
66
|
+
HIDDEN_CONTEXT_KEYS = %w[
|
|
67
|
+
level message timestamp time ts request_id function_name function_version
|
|
68
|
+
action path backtrace error_class error_message
|
|
69
|
+
].freeze
|
|
70
|
+
|
|
65
71
|
def initialize(args)
|
|
66
72
|
@lambda_name = nil
|
|
67
73
|
@env = nil
|
|
@@ -496,7 +502,7 @@ module Belt
|
|
|
496
502
|
|
|
497
503
|
def format_error_log(json, message, timestamp, prefix_str)
|
|
498
504
|
puts "#{prefix_str}#{c(:gray)}#{timestamp}#{c(:reset)} " \
|
|
499
|
-
"#{c(:red)}ERROR#{c(:reset)} #{c(:bold)}#{message}#{c(:reset)}"
|
|
505
|
+
"#{c(:red)}ERROR#{c(:reset)} #{c(:bold)}#{message}#{c(:reset)}#{format_context(json)}"
|
|
500
506
|
puts " #{c(:dim)}Action:#{c(:reset)} #{json['action']}" if json['action']
|
|
501
507
|
if json['error_class']
|
|
502
508
|
puts " #{c(:dim)}Error:#{c(:reset)} " \
|
|
@@ -507,7 +513,8 @@ module Belt
|
|
|
507
513
|
end
|
|
508
514
|
|
|
509
515
|
def format_warn_log(json, message, timestamp, prefix_str)
|
|
510
|
-
puts "#{prefix_str}#{c(:gray)}#{timestamp}#{c(:reset)}
|
|
516
|
+
puts "#{prefix_str}#{c(:gray)}#{timestamp}#{c(:reset)} " \
|
|
517
|
+
"#{c(:yellow)}WARN#{c(:reset)} #{message}#{format_context(json)}"
|
|
511
518
|
if json['error_class']
|
|
512
519
|
puts " #{c(:dim)}Error:#{c(:reset)} " \
|
|
513
520
|
"#{c(:red)}#{json['error_class']}#{c(:reset)}: #{json['error_message']}"
|
|
@@ -530,11 +537,22 @@ module Belt
|
|
|
530
537
|
"#{c(:cyan)}Completed#{c(:reset)} #{c(sc_color)}#{sc}#{c(:reset)} #{path}"
|
|
531
538
|
else
|
|
532
539
|
level = json['level']
|
|
533
|
-
|
|
534
|
-
|
|
540
|
+
return unless level
|
|
541
|
+
|
|
542
|
+
puts "#{prefix_str}#{c(:gray)}#{timestamp}#{c(:reset)} " \
|
|
543
|
+
"#{level_color_for(level)}#{level}#{c(:reset)} #{message}#{format_context(json)}"
|
|
535
544
|
end
|
|
536
545
|
end
|
|
537
546
|
|
|
547
|
+
# Renders extra structured fields (e.g. sku, mode) as dim key=value pairs.
|
|
548
|
+
def format_context(json)
|
|
549
|
+
pairs = json.reject { |k, v| HIDDEN_CONTEXT_KEYS.include?(k) || v.nil? }
|
|
550
|
+
return '' if pairs.empty?
|
|
551
|
+
|
|
552
|
+
formatted = pairs.map { |k, v| "#{k}=#{v.is_a?(String) ? v : v.to_json}" }.join(' ')
|
|
553
|
+
" #{c(:dim)}#{formatted}#{c(:reset)}"
|
|
554
|
+
end
|
|
555
|
+
|
|
538
556
|
def format_aws_error(json, prefix: nil)
|
|
539
557
|
prefix_str = prefix ? "#{c(:blue)}[#{prefix}]#{c(:reset)} " : ''
|
|
540
558
|
puts "#{prefix_str} #{c(:dim)}Error Type:#{c(:reset)} #{c(:red)}#{json['errorType']}#{c(:reset)}"
|
data/lib/belt/version.rb
CHANGED
|
@@ -25,7 +25,9 @@ resource "conveyor_belt" "main" {
|
|
|
25
25
|
source = "${path.module}/../../../config/routes.rb"
|
|
26
26
|
app_name = var.app_name
|
|
27
27
|
lambda_source_dir = "${path.module}/../../../lambda"
|
|
28
|
-
|
|
28
|
+
# "config" ships lambda/config/environment.rb, which the belt-pay and belt-messaging
|
|
29
|
+
# handlers require_relative at boot.
|
|
30
|
+
lambda_shared_dirs = ["config", "controllers", "helpers", "lib", "models", "views"]
|
|
29
31
|
<% if @frontend -%>
|
|
30
32
|
# CloudFront first so SPA→API CORS works out of the box (tutorial footgun fixed).
|
|
31
33
|
# localhost stays via env frontend_urls for local `belt server` dev.
|