Log constructor
Implementation
Log(this.app) {
final tEnvironment = app.environment;
logPrinting = switch (tEnvironment) {
LogEnvironment() => tEnvironment.printLog,
// debugPrint's implementation is actually quite heavy even in release mode.
// So we disable it in release mode.
_ => kDebugMode,
};
setLevelByValue(-kPataInHex);
_rootLogDelegateSubscription = Logger.root.onRecord.listen(
_onRootLogRecordDelegate,
);
if (!kIsWeb) {
_originalOnUnhandledError = PlatformDispatcher.instance.onError;
PlatformDispatcher.instance.onError = _onUnhandledError;
}
_originalOnFlutterError = FlutterError.onError;
FlutterError.onError = _onFlutterError;
App.appStageChangeStream
.firstWhere(
(e) =>
e == app &&
e.stage == AppStage.initializingPluginsWithRemoteConfig,
)
.then((_) {
// When RemoteConfig is ready in our app, start listening
// for RemoteConfig changes and grab and parse our configuration.
_onRemoteConfigChange();
app.remoteConfig.addListener(_onRemoteConfigChange);
});
}