mirror of
https://github.com/linagora/tmail-flutter.git
synced 2026-12-06 16:04:20 +00:00
webConsoleEnabled was deprecated in favour of a global constructor flag, but that removed the ability to force specific log calls visible on web in release/profile mode — a legitimate need for auth and Sentry init diagnostics. Carry webConsoleEnabled through the full pipeline: LogRecord → buildLogRecord → _dispatch → public log functions. ConsoleLogHandler reads the flag from the record rather than from its constructor, so per-call opt-in works independently of build mode. On web: - handles() always returns true (filter deferred to handle()) - handle() prints only when record.webConsoleEnabled || isDebugMode Existing call sites (authorization_interceptors, sentry_config) that pass webConsoleEnabled: true are preserved and functional again.
32 lines
1.3 KiB
Dart
32 lines
1.3 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:core/utils/logging/app_logger_registry.dart';
|
|
import 'package:core/utils/logging/formatters/log_formatter.dart';
|
|
import 'package:core/utils/logging/handlers/console_log_handler.dart';
|
|
import 'package:core/utils/logging/handlers/sentry_breadcrumb_handler.dart';
|
|
import 'package:core/utils/logging/handlers/sentry_event_handler.dart';
|
|
import 'package:core/utils/sentry/sentry_manager.dart';
|
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
|
import 'package:tmail_ui_user/main/runner/app_error_handlers.dart';
|
|
|
|
Future<void> runAppGuarded(Future<void> Function() runner) async {
|
|
SentryWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
setupErrorHooks();
|
|
|
|
await runner();
|
|
}
|
|
|
|
/// Registers all log handlers for the given platform.
|
|
///
|
|
/// Must be called once at app startup, before any log call is made.
|
|
/// Sentry handlers are registered early — they check [SentryManager.isSentryAvailable]
|
|
/// internally, so calls before Sentry initialises are safe no-ops.
|
|
void registerLogHandlers({required LogFormatter formatter}) {
|
|
final sentry = SentryManager.instance;
|
|
AppLoggerRegistry.instance
|
|
..registerHandler(ConsoleLogHandler(formatter: formatter))
|
|
..registerHandler(SentryBreadcrumbHandler(sentry))
|
|
..registerHandler(SentryEventHandler(sentry));
|
|
}
|