mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
More logging
This commit is contained in:
parent
b97a367be7
commit
fc51c1d730
3 changed files with 13 additions and 2 deletions
|
@ -81,6 +81,7 @@ module Spectator
|
||||||
#
|
#
|
||||||
# NOTE: Defining a stub for a method not defined in the double's type has no effect.
|
# NOTE: Defining a stub for a method not defined in the double's type has no effect.
|
||||||
protected def _spectator_define_stub(stub : Stub) : Nil
|
protected def _spectator_define_stub(stub : Stub) : Nil
|
||||||
|
Log.debug { "Defined stub for #{_spectator_stubbed_name} #{stub}" }
|
||||||
@stubs.unshift(stub)
|
@stubs.unshift(stub)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -101,10 +102,12 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
private def _spectator_stub_fallback(call : MethodCall, &)
|
private def _spectator_stub_fallback(call : MethodCall, &)
|
||||||
|
Log.trace { "Fallback for #{call} - call original" }
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
|
|
||||||
private def _spectator_stub_fallback(call : MethodCall, type, &)
|
private def _spectator_stub_fallback(call : MethodCall, type, &)
|
||||||
|
Log.trace { "Fallback for #{call} - call original" }
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -124,7 +127,7 @@ module Spectator
|
||||||
# Handle all methods but only respond to configured messages.
|
# Handle all methods but only respond to configured messages.
|
||||||
# Raises an `UnexpectedMessage` error for non-configures messages.
|
# Raises an `UnexpectedMessage` error for non-configures messages.
|
||||||
macro method_missing(call)
|
macro method_missing(call)
|
||||||
Log.debug { "Got undefined method `{{call.name}}({{*call.args}}{% if call.named_args %}{% unless call.args.empty? %}, {% end %}{{*call.named_args}}{% end %}){% if call.block %} { ... }{% end %}`" }
|
Log.trace { "Got undefined method `{{call.name}}({{*call.args}}{% if call.named_args %}{% unless call.args.empty? %}, {% end %}{{*call.named_args}}{% end %}){% if call.block %} { ... }{% end %}`" }
|
||||||
args = ::Spectator::Arguments.capture({{call.args.splat(", ")}}{% if call.named_args %}{{*call.named_args}}{% end %})
|
args = ::Spectator::Arguments.capture({{call.args.splat(", ")}}{% if call.named_args %}{{*call.named_args}}{% end %})
|
||||||
call = ::Spectator::MethodCall.new({{call.name.symbolize}}, args)
|
call = ::Spectator::MethodCall.new({{call.name.symbolize}}, args)
|
||||||
raise ::Spectator::UnexpectedMessage.new("#{_spectator_stubbed_name} received unexpected message #{call}")
|
raise ::Spectator::UnexpectedMessage.new("#{_spectator_stubbed_name} received unexpected message #{call}")
|
||||||
|
|
|
@ -28,6 +28,8 @@ module Spectator
|
||||||
|
|
||||||
# Handles all messages.
|
# Handles all messages.
|
||||||
macro method_missing(call)
|
macro method_missing(call)
|
||||||
|
Log.trace { "Got undefined method `{{call.name}}({{*call.args}}{% if call.named_args %}{% unless call.args.empty? %}, {% end %}{{*call.named_args}}{% end %}){% if call.block %} { ... }{% end %}`" }
|
||||||
|
|
||||||
# Capture information about the call.
|
# Capture information about the call.
|
||||||
%args = ::Spectator::Arguments.capture({{call.args.splat(", ")}}{% if call.named_args %}{{*call.named_args}}{% end %})
|
%args = ::Spectator::Arguments.capture({{call.args.splat(", ")}}{% if call.named_args %}{{*call.named_args}}{% end %})
|
||||||
%call = ::Spectator::MethodCall.new({{call.name.symbolize}}, %args)
|
%call = ::Spectator::MethodCall.new({{call.name.symbolize}}, %args)
|
||||||
|
|
|
@ -23,22 +23,27 @@ module Spectator
|
||||||
end
|
end
|
||||||
|
|
||||||
private def _spectator_stub_fallback(call : MethodCall, &)
|
private def _spectator_stub_fallback(call : MethodCall, &)
|
||||||
|
Log.trace { "Fallback for #{call} - return self" }
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
private def _spectator_stub_fallback(call : MethodCall, type : self, &)
|
private def _spectator_stub_fallback(call : MethodCall, type : self, &)
|
||||||
|
Log.trace { "Fallback for #{call} - return self" }
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
private def _spectator_stub_fallback(call : MethodCall, type, &)
|
private def _spectator_stub_fallback(call : MethodCall, type, &)
|
||||||
|
Log.trace { "Fallback for #{call} - call original" }
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
|
|
||||||
private def _spectator_abstract_stub_fallback(call : MethodCall)
|
private def _spectator_abstract_stub_fallback(call : MethodCall)
|
||||||
|
Log.trace { "Fallback for #{call} - return self" }
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
private def _spectator_abstract_stub_fallback(call : MethodCall, type : self)
|
private def _spectator_abstract_stub_fallback(call : MethodCall, type : self)
|
||||||
|
Log.trace { "Fallback for #{call} - return self" }
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -48,7 +53,8 @@ module Spectator
|
||||||
|
|
||||||
# Handle all methods but only respond to configured messages.
|
# Handle all methods but only respond to configured messages.
|
||||||
# Returns self.
|
# Returns self.
|
||||||
macro method_missing(_call)
|
macro method_missing(call)
|
||||||
|
Log.trace { "Got undefined method `{{call.name}}({{*call.args}}{% if call.named_args %}{% unless call.args.empty? %}, {% end %}{{*call.named_args}}{% end %}){% if call.block %} { ... }{% end %}` - returning self" }
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue