Skip to content

Commit

Permalink
Logs when a receiver object is found for a particular command.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrekdal committed Sep 24, 2022
1 parent 11a4a27 commit fb11e1e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Command/Emetra.Command.Mediator.pas
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ function TCommandMediator.FindReceiver( const AName: string; out AObject: TRecei
function TCommandMediator.ExecuteCmd( const ACommand: ICommand ): boolean;
const
PROC_NAME = 'ExecuteCmd';
WARN_UNHANDLED_COMMAND = LOG_CLASS_METHOD + 'No modules in the system responded to this command: "%s"';
WARN_UNHANDLED_COMMAND = LOG_CLASS_METHOD + 'No classes in the system want to handle this command: "%s".';
LOG_HANDLED_COMMAND = LOG_CLASS_METHOD + 'The class "%s" is registered as receiver for the command: "%s".';
var
receiverObject: TObject;
receiverInterface: ICommandReceiver;
Expand All @@ -240,6 +241,7 @@ function TCommandMediator.ExecuteCmd( const ACommand: ICommand ): boolean;
Log.SilentError( WARN_UNHANDLED_COMMAND, [ClassName, PROC_NAME, ACommand.Name] )
else if Supports( receiverObject, ICommandReceiver, receiverInterface ) then
try
Log.Event( LOG_HANDLED_COMMAND, [ClassName, PROC_NAME, receiverObject.ClassName, ACommand.Name] );
Result := receiverInterface.ExecuteCmd( ACommand );
except
on E: Exception do
Expand Down

0 comments on commit fb11e1e

Please sign in to comment.