Skip to content
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

Add support for logging #583

Merged
merged 12 commits into from
May 24, 2022
Merged

Add support for logging #583

merged 12 commits into from
May 24, 2022

Conversation

nielsenko
Copy link
Contributor

@nielsenko nielsenko commented May 17, 2022

You can set logger to use with Realm like this:

final logger = Logger('x');
logger.root.level = RealmLogLevel.trace;
Realm.logger = logger;

If nothing is specified, the default logger traces info messages or worse to the console.

@cla-bot cla-bot bot added the cla: yes label May 17, 2022
@nielsenko nielsenko force-pushed the kn/log-callback branch 4 times, most recently from 2d5e79e to ab9e7e0 Compare May 20, 2022 07:36
@nielsenko nielsenko changed the title Add Dart scheduler trampoline for realm_sync_client_config_set_log_callback Add support for logging May 20, 2022
@nielsenko nielsenko marked this pull request as ready for review May 20, 2022 07:43
@nielsenko nielsenko marked this pull request as draft May 20, 2022 08:43
@nielsenko nielsenko requested review from blagoev and desistefanova and removed request for blagoev May 20, 2022 10:01
@nielsenko nielsenko marked this pull request as ready for review May 20, 2022 10:01
@nielsenko nielsenko requested a review from blagoev May 20, 2022 10:12
@nielsenko nielsenko force-pushed the kn/log-callback branch 2 times, most recently from abf144f to 516ae15 Compare May 23, 2022 10:02
Copy link
Member

@nirinchev nirinchev left a comment

Choose a reason for hiding this comment

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

This looks okay, but I have some suggestions for making the API nicer. Also, can we add a test for logging to a file as well as a test where the sync log level differs from the logger log level.

ffigen/sync_client_config.h Show resolved Hide resolved
lib/src/app.dart Outdated Show resolved Hide resolved
lib/src/app.dart Outdated Show resolved Hide resolved
lib/src/realm_class.dart Show resolved Hide resolved
src/sync_client_config.cpp Show resolved Hide resolved
test/app_test.dart Outdated Show resolved Hide resolved
@desistefanova
Copy link
Contributor

Just a reminder to change default logLevel from error to info.

/// Instantiates a new [AppConfiguration] with the specified appId.
  AppConfiguration(
    this.appId, {
    Uri? baseUrl,
    Directory? baseFilePath,
    this.defaultRequestTimeout = const Duration(seconds: 60),
    this.localAppName,
    this.localAppVersion,
    this.metadataEncryptionKey,
    this.metadataPersistenceMode = MetadataPersistenceMode.plaintext,
    this.logLevel = LogLevel.info,
    this.maxConnectionTimeout = const Duration(minutes: 2),
    HttpClient? httpClient,
  })  : baseUrl = baseUrl ?? Uri.parse('https://realm.mongodb.com'),
        baseFilePath = baseFilePath ?? Directory(Configuration.filesPath),
        httpClient = httpClient ?? HttpClient();

CHANGELOG.md Outdated Show resolved Hide resolved
lib/src/realm_class.dart Show resolved Hide resolved
src/sync_client_config.cpp Show resolved Hide resolved
lib/src/app.dart Outdated Show resolved Hide resolved
lib/src/app.dart Outdated Show resolved Hide resolved
lib/src/app.dart Outdated Show resolved Hide resolved
lib/src/native/realm_core.dart Show resolved Hide resolved
lib/src/app.dart Outdated Show resolved Hide resolved
lib/src/native/realm_core.dart Outdated Show resolved Hide resolved
* Remove logger and logLevel from AppConfiguration.
* New RealmLogLevel class define the realm specific levels.
@@ -40,6 +40,8 @@
* Support user profile data. ([#570](https://github.com/realm/realm-dart/pull/570))
* Support flexible synchronization. ([#496](https://github.com/realm/realm-dart/pull/496))
* Added support for DateTime properties. ([#569](https://github.com/realm/realm-dart/pull/569))
* Support setting logger on AppConfiguration. ([#583](https://github.com/realm/realm-dart/pull/583))
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't appear to be correct anymore now that we have a single logger.

src/sync_client_config.cpp Show resolved Hide resolved
@nielsenko nielsenko merged commit 3c19d18 into master May 24, 2022
@nielsenko nielsenko deleted the kn/log-callback branch May 24, 2022 14:57
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants