diff --git a/packages/logging_cloudwatch/amplify_logging_cloudwatch/lib/src/amplify_cloudwatch_logger_plugin.dart b/packages/logging_cloudwatch/amplify_logging_cloudwatch/lib/src/amplify_cloudwatch_logger_plugin.dart index f13d6dbffc..d06246afdf 100644 --- a/packages/logging_cloudwatch/amplify_logging_cloudwatch/lib/src/amplify_cloudwatch_logger_plugin.dart +++ b/packages/logging_cloudwatch/amplify_logging_cloudwatch/lib/src/amplify_cloudwatch_logger_plugin.dart @@ -1,7 +1,6 @@ import 'package:amplify_logging_cloudwatch/src/amplify_log_stream_name_provider.dart'; import 'package:amplify_logging_cloudwatch/src/path_provider/flutter_path_provider.dart'; import 'package:aws_logging_cloudwatch/aws_logging_cloudwatch.dart'; -import 'package:aws_logging_cloudwatch/src/queued_item_store/dart_queued_item_store.dart'; /// {@macro aws_logging_cloudwatch.cloudwatch_logger_plugin} class AmplifyCloudWatchLoggerPlugin extends CloudWatchLoggerPlugin { @@ -17,7 +16,6 @@ class AmplifyCloudWatchLoggerPlugin extends CloudWatchLoggerPlugin { defaultLogStreamNameProvider: AmplifyLogStreamNameProvider().defaultLogStreamName, ), - logStore: DartQueuedItemStore(FlutterPathProvider()), remoteLoggingConstraintProvider: pluginConfig.defaultRemoteConfiguration == null ? null diff --git a/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/cloudwatch_logger_plugin.dart b/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/cloudwatch_logger_plugin.dart index 1b03df8949..d6acd457cb 100644 --- a/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/cloudwatch_logger_plugin.dart +++ b/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/cloudwatch_logger_plugin.dart @@ -8,7 +8,8 @@ import 'package:amplify_core/amplify_core.dart'; // ignore: invalid_use_of_internal_member, implementation_imports import 'package:amplify_core/src/http/amplify_category_method.dart'; import 'package:aws_logging_cloudwatch/aws_logging_cloudwatch.dart'; -import 'package:aws_logging_cloudwatch/src/queued_item_store/in_memory_queued_item_store.dart'; +import 'package:aws_logging_cloudwatch/src/path_provider/app_path_provider.dart'; +import 'package:aws_logging_cloudwatch/src/queued_item_store/dart_queued_item_store.dart'; import 'package:aws_logging_cloudwatch/src/queued_item_store/queued_item_store.dart'; import 'package:aws_logging_cloudwatch/src/sdk/cloud_watch_logs.dart'; import 'package:aws_logging_cloudwatch/src/stoppable_timer.dart'; @@ -54,8 +55,6 @@ class CloudWatchLoggerPlugin extends AWSLoggerPlugin required CloudWatchPluginConfig pluginConfig, RemoteLoggingConstraintProvider? remoteLoggingConstraintProvider, CloudWatchLogStreamProvider? logStreamProvider, - // TODO(nikahsn): remove after moving queued item store implementation from - // amplify_logging_cloudwath to aws_logging_cloudwatch @protected QueuedItemStore? logStore, }) : _enabled = pluginConfig.enable, _pluginConfig = pluginConfig, @@ -71,10 +70,7 @@ class CloudWatchLoggerPlugin extends AWSLoggerPlugin region: pluginConfig.region, credentialsProvider: credentialsProvider, ), - // TODO(nikahsn): move queued item store implementation from - // amplify_logging_cloudwath to aws_logging_cloudwatch and use - // DartQueueItemStore instead of InMemoryQueuedItemStore - _logStore = logStore ?? InMemoryQueuedItemStore(), + _logStore = logStore ?? DartQueuedItemStore(const DartAppPathProvider()), _logStreamProvider = logStreamProvider ?? DefaultCloudWatchLogStreamProvider( logGroupName: pluginConfig.logGroupName, diff --git a/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/path_provider/app_path_provider.dart b/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/path_provider/app_path_provider.dart new file mode 100644 index 0000000000..646ebc61d7 --- /dev/null +++ b/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/path_provider/app_path_provider.dart @@ -0,0 +1,6 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +export 'app_path_provider_stub.dart' + if (dart.library.html) 'app_path_provider_html.dart' + if (dart.library.io) 'app_path_provider_io.dart'; diff --git a/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/path_provider/app_path_provider_html.dart b/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/path_provider/app_path_provider_html.dart new file mode 100644 index 0000000000..5bae46ad43 --- /dev/null +++ b/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/path_provider/app_path_provider_html.dart @@ -0,0 +1,22 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +import 'package:amplify_core/amplify_core.dart'; + +/// {@template aws_logging_cloudwatch.app_path_provider} +/// Provides App paths for amplify_storage_s3_dart package. +/// {@endtemplate} +class DartAppPathProvider implements AppPathProvider { + /// {@macro aws_logging_cloudwatch.app_path_provider} + const DartAppPathProvider(); + + @override + Future getApplicationSupportPath() async { + return ''; + } + + @override + Future getTemporaryPath() async { + return ''; + } +} diff --git a/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/path_provider/app_path_provider_io.dart b/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/path_provider/app_path_provider_io.dart new file mode 100644 index 0000000000..d800682af2 --- /dev/null +++ b/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/path_provider/app_path_provider_io.dart @@ -0,0 +1,24 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +import 'dart:io'; + +import 'package:amplify_core/amplify_core.dart'; + +/// {@template aws_logging_cloudwatch.app_path_provider} +/// Provides App paths for amplify_storage_s3_dart package. +/// {@endtemplate} +class DartAppPathProvider implements AppPathProvider { + /// {@macro aws_logging_cloudwatch.app_path_provider} + const DartAppPathProvider(); + + @override + Future getApplicationSupportPath() async { + return Directory.current.path; + } + + @override + Future getTemporaryPath() async { + return Directory.systemTemp.path; + } +} diff --git a/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/path_provider/app_path_provider_stub.dart b/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/path_provider/app_path_provider_stub.dart new file mode 100644 index 0000000000..5f3afd0156 --- /dev/null +++ b/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/path_provider/app_path_provider_stub.dart @@ -0,0 +1,26 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +import 'package:amplify_core/amplify_core.dart'; + +/// {@template aws_logging_cloudwatch.app_path_provider} +/// Provides App paths for amplify_storage_s3_dart package. +/// {@endtemplate} +class DartAppPathProvider implements AppPathProvider { + /// {@macro aws_logging_cloudwatch.app_path_provider} + const DartAppPathProvider(); + + @override + Future getApplicationSupportPath() async { + throw UnimplementedError( + 'getApplicationSupportPath() has not been implemented in the current platform.', + ); + } + + @override + Future getTemporaryPath() async { + throw UnimplementedError( + 'getTemporaryPath() has not been implemented in the current platform.', + ); + } +}