Skip to content

Commit

Permalink
feat(logging):send amplify library logs to cloudwatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Nika Hassani committed Oct 3, 2023
1 parent d134ed5 commit 723398b
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:meta/meta.dart';
/// {@macro amplify_core.logger.amplify_logging_cloudwatch}
class AmplifyFlutterLogging extends AmplifyLogging {
static AmplifyCloudWatchLoggerPlugin? _plugin;
static final _logger = AmplifyLogger();
static final _logger = AWSLogger();

@override
void configure(
Expand Down Expand Up @@ -44,7 +44,9 @@ class AmplifyFlutterLogging extends AmplifyLogging {
credentialsProvider: credentialsProvider,
pluginConfig: pluginConfig,
);
_logger.registerPlugin(_plugin!);
_logger
..registerPlugin(_plugin!)
..logLevel = LogLevel.verbose;
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import 'package:meta/meta.dart';

/// {@template amplify_core.logger.amplify_logging_cloudwatch}
/// It configures the [CloudWatchLoggerPlugin] from [AmplifyConfig] to sends
/// [AmplifyLogger]'s logs to the CloudWatch.
/// [AWSLogger]'s logs to the CloudWatch.
/// {@endtemplate}
class AmplifyLogging {
static CloudWatchLoggerPlugin? _plugin;
static final _logger = AmplifyLogger();
static final _logger = AWSLogger();

void configure(
AmplifyConfig amplifyConfig,
Expand Down Expand Up @@ -43,7 +43,9 @@ class AmplifyLogging {
credentialsProvider: credentialsProvider,
pluginConfig: pluginConfig,
);
_logger.registerPlugin(_plugin!);
_logger
..registerPlugin(_plugin!)
..logLevel = LogLevel.verbose;
}

@visibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ abstract class StateMachineManager<
E extends StateMachineEvent,
S extends StateMachineState,
Manager extends StateMachineManager<E, S, Manager>>
with Dispatcher<E, S>, AWSDebuggable, AWSLoggerMixin
with Dispatcher<E, S>, AWSDebuggable, AmplifyLoggerMixin
implements DependencyManager, Closeable {
/// {@macro amplify_core.state_machinedispatcher}
StateMachineManager(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

import 'package:amplify_analytics_pinpoint_dart/src/impl/analytics_client/event_client/queued_item_store/index_db/in_memory_queued_item_store.dart';
import 'package:amplify_analytics_pinpoint_dart/src/impl/analytics_client/event_client/queued_item_store/index_db/indexed_db_adapter.dart';

import 'package:amplify_analytics_pinpoint_dart/src/impl/analytics_client/event_client/queued_item_store/queued_item_store.dart';
import 'package:aws_common/aws_common.dart';
import 'package:amplify_core/amplify_core.dart';
import 'package:meta/meta.dart';

/// {@macro amplify_analytics_pinpoint_dart.dart_queued_item_store}
class DartQueuedItemStore
with AWSDebuggable, AWSLoggerMixin
with AWSDebuggable, AmplifyLoggerMixin
implements QueuedItemStore, Closeable {
/// {@macro amplify_analytics_pinpoint_dart.index_db_queued_item_store}
// ignore: avoid_unused_constructor_parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:async/async.dart';
/// Provides user context data as required for Cognito's advanced security features
/// (ASF) functionality.
/// {@endtemplate}
final class ASFContextDataProvider with AWSDebuggable, AWSLoggerMixin {
final class ASFContextDataProvider with AWSDebuggable, AmplifyLoggerMixin {
/// {@macro amplify_auth_cognito_dart.asf.asf_context_data_provider}
ASFContextDataProvider(this._dependencyManager);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ abstract base class ASFDeviceInfoCollector {
/// {@endtemplate}
@internal
abstract base class NativeASFDeviceInfoCollector extends ASFDeviceInfoCollector
with AWSDebuggable, AWSLoggerMixin {
with AWSDebuggable, AmplifyLoggerMixin {
/// {@macro amplify_auth_cognito_dart.asf.asf_device_info}
const NativeASFDeviceInfoCollector() : super.base();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Future<void> main() async {

await Amplify.addPlugin(authPlugin);
await Amplify.configure(amplifyConfig);
AmplifyLogger().logLevel = LogLevel.verbose;

runApp(
const MyApp(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

// ignore_for_file: implementation_imports

import 'package:amplify_core/amplify_core.dart';
import 'package:amplify_logging_cloudwatch/src/queued_item_store/index_db/indexed_db_adapter.dart';
import 'package:aws_common/aws_common.dart';
import 'package:aws_logging_cloudwatch/src/queued_item_store/in_memory_queued_item_store.dart';
import 'package:aws_logging_cloudwatch/src/queued_item_store/queued_item_store.dart';
import 'package:meta/meta.dart';

/// {@macro amplify_logging_cloudwatch.dart_queued_item_store}
class DartQueuedItemStore
with AWSDebuggable, AWSLoggerMixin
with AWSDebuggable, AmplifyLoggerMixin
implements QueuedItemStore, Closeable {
/// {@macro amplify_logging_cloudwatch.index_db_queued_item_store}
// ignore: avoid_unused_constructor_parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ bool get _zIsTest => Zone.current[zIsTest] as bool? ?? false;
/// The Dart Storage S3 plugin for the Amplify Storage Category.
/// {@endtemplate}
class AmplifyStorageS3Dart extends StoragePluginInterface
with AWSDebuggable, AWSLoggerMixin {
with AWSDebuggable, AmplifyLoggerMixin {
/// {@macro amplify_storage_s3_dart.amplify_storage_s3_plugin_dart}
AmplifyStorageS3Dart({
String? delimiter,
Expand Down

0 comments on commit 723398b

Please sign in to comment.