Skip to content

Commit c4b30ff

Browse files
authored
Add region to log formatter (#2851)
1 parent c070d8b commit c4b30ff

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

gems/aws-sdk-core/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Unreleased Changes
22
------------------
33

4+
* Feature - Add :region option to `Aws::Log::Formatter`.
5+
46
3.171.1 (2023-05-04)
57
------------------
68

gems/aws-sdk-core/lib/aws-sdk-core/log/formatter.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ module Log
2626
#
2727
# You can put any of these placeholders into you pattern.
2828
#
29+
# * `:region` - The region configured for the client.
30+
#
2931
# * `:client_class` - The name of the client class.
3032
#
3133
# * `:operation` - The name of the client request method.
@@ -116,6 +118,10 @@ def method_missing(method_name, *args)
116118

117119
private
118120

121+
def _region(response)
122+
response.context.config.region
123+
end
124+
119125
def _client_class(response)
120126
response.context.client.class.name
121127
end

gems/aws-sdk-core/spec/aws/log/formatter_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ def format(pattern, options = {})
1818
end
1919

2020
describe '#format' do
21+
it 'provides a :region replacement' do
22+
response.context.config.region = 'us-peccy-1'
23+
expect(format(':region')).to eq('us-peccy-1')
24+
end
25+
2126
it 'provides a :client_class replacement' do
2227
response.context.client = String.new
2328
expect(format(':client_class')).to eq('String')

0 commit comments

Comments
 (0)