Skip to content

Commit

Permalink
Refactor ControllerObserver to log the duration of handler execution
Browse files Browse the repository at this point in the history
  • Loading branch information
PlugFox committed Oct 16, 2024
1 parent 5b122c4 commit b3e1eca
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,20 @@ final class ControllerObserver implements IControllerObserver {

@override
void onHandler(HandlerContext context) {
final stopwatch = Stopwatch()..start();
l.d(
'Controller | ' '${context.controller.name}.${context.name}',
context.meta,
);
context.done.whenComplete(() {
stopwatch.stop();
l.d(
'Controller | '
'${context.controller.name}.${context.name} | '
'duration: ${stopwatch.elapsed}',
context.meta,
);
});
}

@override
Expand Down

0 comments on commit b3e1eca

Please sign in to comment.