Skip to content

Commit

Permalink
Add debug info for log device
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyCTHsu committed Jun 10, 2024
1 parent d673469 commit e0c68c4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ test_containers:
DD_AGENT_HOST: testagent
DD_TRACE_AGENT_PORT: 9126
DATADOG_GEM_CI: true
RUBYOPT: -r/app/patch_log_device
- &container_parameters_environment
- *container_base_environment
- TEST_DATADOG_INTEGRATION: 1
Expand Down
16 changes: 16 additions & 0 deletions patch_log_device.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
if RUBY_ENGINE == 'jruby'
require 'logger'
::Logger::LogDevice.prepend(
Module.new do
def write(message)
$stdout.puts("[Writing] ProcessID: #{Process.pid}, ThreadID: #{Thread.current.object_id}, Message: #{message}")
super(message)
end

def close
$stdout.puts("[Closing] ProcessID: #{Process.pid}, ThreadID: #{Thread.current.object_id}")
super
end
end
)
end
4 changes: 2 additions & 2 deletions spec/datadog/core/environment/execution_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
f.close

out, = Open3.capture2e('pry', '-f', '--noprompt', f.path)
expect(out).to eq('ACTUAL:true')
expect(out).to be_end_with('ACTUAL:true')
end
end
end
Expand Down Expand Up @@ -275,7 +275,7 @@ def test_it_does_something_useful
end

expect(err).to be_empty
expect(out).to eq('true')
expect(out).to be_end_with('true')
end
end
end
Expand Down

0 comments on commit e0c68c4

Please sign in to comment.