LogExt<Input, Output> extension

Extension that adds the logEvents and log methods to the ParameterizedResultInteractor class. These methods allow you to log the start, success, and error events of the interactor. You can specify custom log messages for each event. The logEvents method allows you to specify a different log message for each event.

Example:

final interactor = MyInteractor();
await interactor
 .logEvents(
    logStart: (input) => print('MyInteractor started with $input'),
    logSuccess: (duration, output) => print('MyInteractor completed after $duration with $output'),
    logError: (duration, exception) => print('MyInteractor failed after $duration with $exception'),
  )
  .run(input);

The log method allows you to specify a tag for the log messages. The tag will be prepended to the log messages. This could be useful if you want to differentiate between different events produced by the interactor. For example, you could log all errors produced by the interactor into a file rather than the console.

Example:

final interactor = MyInteractor();
await interactor
  .log(
    tag: 'MyInteractor',
    logStart: (message) => stdout.writeln(message),
    logSuccess: (message) => stdout.writeln(message),
    logError: (message) => stderr.writeln(message),
  )
  .run(input);
on

Methods

log({required String tag, required FutureOr<void> logStart(String), required FutureOr<void> logSuccess(String), required FutureOr<void> logError(String)}) ParameterizedResultInteractor<Input, Output>

Available on ParameterizedResultInteractor<Input, Output>, provided by the LogExt extension

logEvents({required FutureOr<void> logStart(Input), required FutureOr<void> logSuccess(Duration, Output), required FutureOr<void> logError(Duration, Exception)}) ParameterizedResultInteractor<Input, Output>

Available on ParameterizedResultInteractor<Input, Output>, provided by the LogExt extension