Skip to content

Commit 6ddfb9c

Browse files
elspethsoupjdantonio
authored andcommitted
Put debug log statement inside block
This prevents potentially expense calls to #inspect and avoids creating a lot of useless string for applications that send a lot of messages to actors.
1 parent d64a7ff commit 6ddfb9c

File tree

6 files changed

+6
-7
lines changed

6 files changed

+6
-7
lines changed

lib/concurrent/actor/behaviour/abstract.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ module Behaviour
66
class Abstract
77
include TypeCheck
88
include InternalDelegations
9-
include Concern::Logging
109

1110
attr_reader :core, :subsequent
1211

@@ -42,7 +41,7 @@ def broadcast(public, event)
4241
def reject_envelope(envelope)
4342
envelope.reject! ActorTerminated.new(reference)
4443
dead_letter_routing << envelope unless envelope.future
45-
log DEBUG, "rejected #{envelope.message} from #{envelope.sender_path}"
44+
log(DEBUG) { "rejected #{envelope.message} from #{envelope.sender_path}"}
4645
end
4746
end
4847
end

lib/concurrent/actor/behaviour/sets_results.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def on_envelope(envelope)
1414
result = pass envelope
1515
if result != MESSAGE_PROCESSED && !envelope.future.nil?
1616
envelope.future.success result
17-
log DEBUG, "finished processing of #{envelope.message.inspect}"
17+
log(DEBUG) { "finished processing of #{envelope.message.inspect}"}
1818
end
1919
nil
2020
rescue => error

lib/concurrent/actor/context.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ module Actor
2424
class AbstractContext
2525
include TypeCheck
2626
include InternalDelegations
27-
include Concern::Logging
2827

2928
attr_reader :core
3029

lib/concurrent/actor/core.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def remove_child(child)
9191
# @param [Envelope] envelope
9292
def on_envelope(envelope)
9393
schedule_execution do
94-
log DEBUG, "was #{envelope.future ? 'asked' : 'told'} #{envelope.message.inspect} by #{envelope.sender}"
94+
log(DEBUG) { "was #{envelope.future ? 'asked' : 'told'} #{envelope.message.inspect} by #{envelope.sender}" }
9595
process_envelope envelope
9696
end
9797
nil
@@ -128,7 +128,7 @@ def schedule_execution
128128
end
129129

130130
def broadcast(public, event)
131-
log DEBUG, "event: #{event.inspect} (#{public ? 'public' : 'private'})"
131+
log(DEBUG) { "event: #{event.inspect} (#{public ? 'public' : 'private'})" }
132132
@first_behaviour.on_event(public, event)
133133
end
134134

lib/concurrent/actor/default_dead_letter_handler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module Concurrent
22
module Actor
33
class DefaultDeadLetterHandler < RestartingContext
44
def on_message(dead_letter)
5-
log INFO, "got dead letter #{dead_letter.inspect}"
5+
log(INFO) { "got dead letter #{dead_letter.inspect}"}
66
end
77
end
88
end

lib/concurrent/actor/internal_delegations.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module Concurrent
22
module Actor
33
module InternalDelegations
44
include PublicDelegations
5+
include Logger::Severity
56

67
# @see Core#children
78
def children

0 commit comments

Comments
 (0)