Files
GeoShare/bin/middleware/request_logger.dart
dmit.b fde96c0197 feat: add Swagger UI docs, custom CORS middleware, and request logging
- Add Swagger UI files and updated API spec for Family Safety Tracker
- Replace shelf_cors_headers with custom CORS middleware in server.dart
- Add request_logger middleware with timing for auth and geo routes
- Add REGISTRATION_SECRET_KEY to .env for registration validation
- Remove postgres port exposure from docker-compose.yml
- Update opencode.json model configuration
- Add crypto dependency and update Flutter web assets
2026-05-15 17:43:53 +03:00

27 lines
790 B
Dart

void logRequest({
required String method,
required String url,
required int status,
required Duration duration,
DateTime? startTime,
String? body,
Map<String, String>? responseHeaders,
}) {
final start = startTime ?? DateTime.now();
final timestamp = start.toIso8601String();
final durationMs = duration.inMilliseconds;
final bodyPreview = body != null && body.length > 500 ? '${body.substring(0, 500)}...' : body;
print('[$timestamp] $method $url -> $status (${durationMs}ms)');
if (bodyPreview != null && bodyPreview.isNotEmpty) {
print(' Body: $bodyPreview');
}
if (responseHeaders != null) {
final contentType = responseHeaders['content-type'];
if (contentType != null) {
print(' Content-Type: $contentType');
}
}
print('');
}