Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt default Rails mails logs to JSON format #15894

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ group :assets do
gem "compass", "1.0.3"
end

gem 'cartodb-common', git: 'https://github.com/cartodb/cartodb-common.git', tag: 'v0.3.7'
gem 'roo', '1.13.2'
gem 'state_machines-activerecord', '~> 0.5.0'
gem 'typhoeus', '1.3.1'
Expand All @@ -64,7 +65,6 @@ gem 'gibbon', '1.1.4'
gem 'instagram-continued-continued'
gem 'google-cloud-pubsub', '1.2.0'
gem 'virtus', '1.0.5'
gem 'cartodb-common', git: 'https://github.com/cartodb/cartodb-common.git', tag: 'v0.3.6'
gem 'email_address', '~> 0.1.11'
gem 'redcarpet', '3.3.3'
gem 'rollbar', '~>2.11.1'
Expand Down
18 changes: 9 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ GIT

GIT
remote: https://github.com/cartodb/cartodb-common.git
revision: d6f603d4324587de1ae0b60af14856e2935af75c
tag: v0.3.6
revision: f098950c5fee57686718fea112d198e6e5e3dfd9
tag: v0.3.7
specs:
cartodb-common (0.3.6)
activesupport (~> 4.2.11.3)
Expand Down Expand Up @@ -270,7 +270,7 @@ GEM
mime-types-data (3.2020.0512)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.1)
minitest (5.14.2)
mocha (1.1.0)
metaclass (~> 0.0.1)
mock_redis (0.25.0)
Expand All @@ -293,7 +293,7 @@ GEM
rack (>= 1.2, < 3)
os (1.1.1)
parallel (1.19.2)
parser (2.7.1.5)
parser (2.7.2.0)
ast (~> 2.4.1)
pg (0.20.0)
poltergeist (1.18.1)
Expand Down Expand Up @@ -356,7 +356,7 @@ GEM
redis (3.3.5)
redis-namespace (1.7.0)
redis (>= 3.0.4)
regexp_parser (1.8.0)
regexp_parser (1.8.2)
representable (3.0.4)
declarative (< 0.1.0)
declarative-option (< 0.2.0)
Expand Down Expand Up @@ -396,16 +396,16 @@ GEM
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
rspec-mocks (~> 2.12.0)
rubocop (0.92.0)
rubocop (0.93.1)
parallel (~> 1.10)
parser (>= 2.7.1.5)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
regexp_parser (>= 1.8)
rexml
rubocop-ast (>= 0.5.0)
rubocop-ast (>= 0.6.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.5.0)
rubocop-ast (1.0.1)
parser (>= 2.7.1.5)
rubocop-rails (2.8.1)
activesupport (>= 4.2.0)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ WORKING_SPECS_1 = \
spec/requests/sessions_controller_spec.rb \
spec/services/carto/visualizations_export_service_2_spec.rb \
spec/services/carto/visualization_backup_service_spec.rb \
spec/requests/carto_logger_spec.rb \
spec/lib/carto/common/logger_spec.rb \
$(NULL)

WORKING_SPECS_2 = \
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Development
* Avoid delegating special methods in presenters [#15889](https://github.com/CartoDB/cartodb/pull/15889)
* Fix Dashboard/Data navigation for free users. Update Data preview texts [#15892](https://github.com/CartoDB/cartodb/pull/15892)
* Force CTE materialization in Ghost Tables query to improve performance [#15895](https://github.com/CartoDB/cartodb/pull/15895)
* Adapt default Rails mail logs to JSON format [#15894](https://github.com/CartoDB/cartodb/pull/15894)

4.42.0 (2020-09-28)
-------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
include_context 'users helper'

class LogDeviceMock < Logger::LogDevice

attr_accessor :written_text

def write(text)
Expand All @@ -17,12 +18,13 @@ def write(text)

def self.capture_output
original_log_device = Rails.logger.instance_variable_get(:@logdev)
mock_log_device = self.new('fake.log')
mock_log_device = new('fake.log')
Rails.logger.instance_variable_set(:@logdev, mock_log_device)
yield
Rails.logger.instance_variable_set(:@logdev, original_log_device)
mock_log_device.written_text
end

end

let!(:user) do
Expand Down Expand Up @@ -91,4 +93,10 @@ def self.capture_output
expect(output).to match(/"request_id":"1234".*"filter":":builder_users_only\".*"event_message":"Filter chain halted \(rendered or redirected\)"/)
end

it 'logs when an emails was sent' do
output = LogDeviceMock.capture_output { user.carto_user.send_password_reset! }

expect(output).to match(/"event_message":"Mail processed"/)
expect(output).to match(/"event_message":"Mail sent"/)
end
end