@@ -3,6 +3,10 @@ import 'dart:io';
3
3
import 'package:dart_frog/dart_frog.dart' ;
4
4
import 'package:ht_api/src/services/auth_service.dart' ;
5
5
import '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' );
6
10
7
11
/// Handles POST requests to `/api/v1/auth/sign-out` .
8
12
///
@@ -34,8 +38,8 @@ Future<Response> onRequest(RequestContext context) async {
34
38
// Although authentication middleware should ensure a token is present,
35
39
// this check acts as a safeguard.
36
40
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.' ,
39
43
);
40
44
throw const OperationFailedException (
41
45
'Internal error: Unable to retrieve authentication token for sign-out.' ,
@@ -55,9 +59,13 @@ Future<Response> onRequest(RequestContext context) async {
55
59
} on HtHttpException catch (_) {
56
60
// Let the central errorHandler middleware handle known exceptions
57
61
rethrow ;
58
- } catch (e) {
62
+ } catch (e, s ) {
59
63
// 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
+ );
61
69
// Let the central errorHandler handle this as a 500
62
70
throw const OperationFailedException (
63
71
'An unexpected error occurred during sign-out.' ,
0 commit comments