Skip to content

Fix bugs #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/app/bloc/app_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,9 @@ class AppBloc extends Bloc<AppEvent, AppState> {
);

try {
final appConfig = await _appConfigRepository.read(id: 'app_config');
final remoteConfig = await _appConfigRepository.read(id: kRemoteConfigId);
print(
'[AppBloc] AppConfig fetched successfully. ID: ${appConfig.id} for user: ${state.user!.id}',
'[AppBloc] Remote Config fetched successfully. ID: ${remoteConfig.id} for user: ${state.user!.id}',
);
Comment on lines 436 to 438

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using print() for logging is generally discouraged in production applications. It's better to use a dedicated logging package (like package:logging, which seems to be used in bootstrap.dart) to have more control over log levels, output, and performance.

Benefits of using a Logger:

  • Log Levels: Differentiate between debug, info, warning, and error messages.
  • Configurability: Easily enable/disable or redirect logs for different build environments (e.g., disable verbose logs in release builds).
  • Structured Logging: Provides more context and is easier to parse by logging services.

Consider injecting a Logger instance into AppBloc and using it for all logging throughout the file.


// Determine the correct status based on the existing user's role.
Expand All @@ -444,7 +444,10 @@ class AppBloc extends Bloc<AppEvent, AppState> {
? AppStatus.authenticated
: AppStatus.anonymous;
emit(
state.copyWith(remoteConfig: appConfig, status: newStatusBasedOnUser),
state.copyWith(
remoteConfig: remoteConfig,
status: newStatusBasedOnUser,
),
);
} on HtHttpException catch (e) {
print(
Expand Down
1 change: 0 additions & 1 deletion lib/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Future<Widget> bootstrap(
httpClient = HtHttpClient(
baseUrl: appConfig.baseUrl,
tokenProvider: () => authenticationRepository.getAuthToken(),
isWeb: kIsWeb,
logger: logger,
);
authClient = HtAuthApi(httpClient: httpClient);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ packages:
description:
path: "."
ref: HEAD
resolved-ref: "6484a5641c3d633d286ea5848c5b7cf1e723ebc1"
resolved-ref: "3c50cd082406d4cacafe60ad097ba6fa6ba891eb"
url: "https://github.com/headlines-toolkit/ht-http-client.git"
source: git
version: "0.0.0"
Expand Down
Loading