@@ -3,6 +3,10 @@ import 'dart:io';
33import 'package:dart_frog/dart_frog.dart' ;
44import 'package:ht_api/src/services/auth_service.dart' ;
55import 'package:ht_shared/ht_shared.dart' ; // For User and exceptions
6+ import 'package:logging/logging.dart' ;
7+
8+ // Create a logger for this file.
9+ final _logger = Logger ('sign_out_handler' );
610
711/// Handles POST requests to `/api/v1/auth/sign-out` .
812///
@@ -34,8 +38,8 @@ Future<Response> onRequest(RequestContext context) async {
3438 // Although authentication middleware should ensure a token is present,
3539 // this check acts as a safeguard.
3640 if (token == null || token.isEmpty) {
37- print (
38- 'Error: Could not extract Bearer token for user ${user .id } in sign-out handler.' ,
41+ _logger. severe (
42+ 'Could not extract Bearer token for user ${user .id } in sign-out handler.' ,
3943 );
4044 throw const OperationFailedException (
4145 'Internal error: Unable to retrieve authentication token for sign-out.' ,
@@ -55,9 +59,13 @@ Future<Response> onRequest(RequestContext context) async {
5559 } on HtHttpException catch (_) {
5660 // Let the central errorHandler middleware handle known exceptions
5761 rethrow ;
58- } catch (e) {
62+ } catch (e, s ) {
5963 // Catch unexpected errors from the service layer
60- print ('Unexpected error in /sign-out handler for user ${user .id }: $e ' );
64+ _logger.severe (
65+ 'Unexpected error in /sign-out handler for user ${user .id }' ,
66+ e,
67+ s,
68+ );
6169 // Let the central errorHandler handle this as a 500
6270 throw const OperationFailedException (
6371 'An unexpected error occurred during sign-out.' ,
0 commit comments