Skip to content

Commit a8eff43

Browse files
committed
feat(api): add diagnostic logging for environment variables
Enhances `EnvironmentConfig` to log all available environment variables if `DATABASE_URL` is not found. This provides crucial diagnostic information to debug configuration issues where environment variables are not being loaded as expected.
1 parent f769493 commit a8eff43

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/src/config/environment_config.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:io';
2+
import 'package:logging/logging.dart';
23

34
/// {@template environment_config}
45
/// A utility class for accessing environment variables.
@@ -9,6 +10,7 @@ import 'dart:io';
910
/// {@endtemplate}
1011
abstract final class EnvironmentConfig {
1112
/// Retrieves the PostgreSQL database connection URI from the environment.
13+
static final _log = Logger('EnvironmentConfig');
1214
///
1315
/// The value is read from the `DATABASE_URL` environment variable.
1416
///
@@ -17,6 +19,12 @@ abstract final class EnvironmentConfig {
1719
static String get databaseUrl {
1820
final dbUrl = Platform.environment['DATABASE_URL'];
1921
if (dbUrl == null || dbUrl.isEmpty) {
22+
_log.severe(
23+
'DATABASE_URL not found. Dumping available environment variables:',
24+
);
25+
Platform.environment.forEach((key, value) {
26+
_log.severe(' - $key: $value');
27+
});
2028
throw StateError(
2129
'FATAL: DATABASE_URL environment variable is not set. '
2230
'The application cannot start without a database connection.',

0 commit comments

Comments
 (0)