Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: LJ <[email protected]>
  • Loading branch information
kneth and elle-j authored Mar 6, 2024
1 parent c3ffbe6 commit 2e23839
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## vNext (TBD)

NOTE: This version bumps the Realm file format to version 24. It is not possible to downgrade to earlier versions. Older files will automatically be upgraded to the new file format. Files created by Realm JavaScript prior to v6.0.0, might not be upgradeable. Only Realm Studio 15.0.0 or later will be able to open the new file format.
> [!NOTE]
> This version bumps the Realm file format to version 24. It is not possible to downgrade to earlier versions. Older files will automatically be upgraded to the new file format. Files created by Realm JavaScript prior to v6.0.0, might not be upgradeable. **Only Realm Studio 15.0.0 or later** will be able to open the new file format.

### Deprecations
* None
Expand All @@ -17,13 +18,13 @@ NOTE: This version bumps the Realm file format to version 24. It is not possible
* Added support for using aggregate operations on Mixed properties in queries. ([realm/realm-core#7398](https://github.com/realm/realm-core/pull/7398))

### Fixed
* Align dictionaries to Lists and Sets when they get cleared. ([#6205](https://github.com/realm/realm-core/issues/6205), since v10.3.0-rc.1)
* Aligned Dictionaries to Lists and Sets when they get cleared. ([#6205](https://github.com/realm/realm-core/issues/6205), since v10.3.0-rc.1)
* Fixed equality queries on a `Mixed` property with an index possibly returning the wrong result if values of different types happened to have the same StringIndex hash. ([realm/realm-core#6407](https://github.com/realm/realm-core/issues/6407), since v10.5.0-beta.1)
* `@count`/`@size` not supported for `Mixed` properties. ([realm/realm-core#7280](https://github.com/realm/realm-core/issues/7280), since v10.0.0)
* `@count`/`@size` is now supported for `Mixed` properties. ([realm/realm-core#7280](https://github.com/realm/realm-core/issues/7280), since v10.0.0)
* Fixed queries like `indexed_property == NONE {x}` which mistakenly matched on only `x` instead of not `x`. This only applies when an indexed property with equality (`==`, or `IN`) matches with `NONE` on a list of one item. If the constant list contained more than one value then it was working correctly. ([realm/realm-java#7862](https://github.com/realm/realm-java/issues/7862), since v10.20.0)
* Uploading the changesets recovered during an automatic client reset recovery may lead to `Bad server version` errors and a new client reset. ([realm/realm-core#7279](https://github.com/realm/realm-core/issues/7279), since v12.5.0)
* Fixed crash in full text index using prefix search with no matches ([realm/realm-core#7309](https://github.com/realm/realm-core/issues/7309), since v12.2.0)
* Fix a race condition when backing up Realm files before a client reset which could have lead to overwriting an existing file. ([realm/realm-core#7341](https://github.com/realm/realm-core/pull/7341)).
* Fixed a race condition when backing up Realm files before a client reset which could have lead to overwriting an existing file. ([realm/realm-core#7341](https://github.com/realm/realm-core/pull/7341)).

### Compatibility
* React Native >= v0.71.4
Expand Down
8 changes: 6 additions & 2 deletions packages/realm/src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export type LogOptions = {
export type Logger = (level: NumericLogLevel, message: string) => void;

/**
* A callback passed to `Realm.setLogger`.
* A callback to be used as the logger.
* @param level - The level of the log entry.
* @param message - The message of the log entry.
* @since 12.0.0
Expand All @@ -195,10 +195,14 @@ export type LogEntry = {
};

/**
* A callback passed to `Realm.setLogger`. Arguments are passed as an object.
* A callback to be used as the logger.
* @since 12.7.0
*/
export type LoggerCallback2 = (entry: LogEntry) => void;
/**
* A callback to be used as the logger.
* @since 12.7.0
*/
export type LoggerCallback = LoggerCallback1 | LoggerCallback2;

/** @internal */
Expand Down
9 changes: 3 additions & 6 deletions packages/realm/src/Realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export class Realm {
* Realm.setLogLevel({ category: LogCategory.Realm, level: "all" });
*/
static setLogLevel(options: LogOptions): void;

static setLogLevel(arg: LogLevel | LogOptions) {
const setLevel = (level: LogLevel, category = LogCategory.Realm) => {
assert(Object.values(LogCategory).includes(category), `Unexpected log category: '${category}'`);
Expand All @@ -147,7 +146,7 @@ export class Realm {
/**
* Sets the logger callback.
* @param loggerCallback - The callback invoked by the logger. The default callback uses `console.log`, `console.warn` and `console.error`, depending on the level of the message.
* @note The logger callback needs to be setup before opening the first Realm.
* @note The logger callback needs to be set up before opening the first Realm.
* @since 12.0.0
* @deprecated Pass a callback taking a single object argument instead.
* @example
Expand All @@ -156,23 +155,21 @@ export class Realm {
* });
*/
static setLogger(loggerCallback: LoggerCallback1): void;

/**
* Sets the logger callback.
* @param loggerCallback - The callback invoked by the logger. The default callback uses `console.log`, `console.warn` and `console.error`, depending on the level of the message.
* @note The logger callback needs to be setup before opening the first Realm.
* @note The logger callback needs to be set up before opening the first Realm.
* @since 12.0.0
* @example
* Realm.setLogger(({ category, level, message }) => {
* console.log(`[${category} - ${level}] ${message}`);
* });
*/
static setLogger(loggerCallback: LoggerCallback2): void;

/**
* Sets the logger callback.
* @param loggerCallback - The callback invoked by the logger. The default callback uses `console.log`, `console.warn` and `console.error`, depending on the level of the message.
* @note The logger callback needs to be setup before opening the first Realm.
* @note The logger callback needs to be set up before opening the first Realm.
* @since 12.0.0
* @example
* Realm.setLogger(({ category, level, message }) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/realm/src/app-services/Sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class Sync {

/** @deprecated Will be removed in v13.0.0. Please use {@link Realm.setLogger}. */
static setLogger(app: App, logger: Logger) {
const factory = binding.Helpers.makeLoggerFactory((category, level, message) => {
const factory = binding.Helpers.makeLoggerFactory((_, level, message) => {
logger(fromBindingLoggerLevelToNumericLogLevel(level), message);
});
app.internal.syncManager.setLoggerFactory(factory);
Expand Down

0 comments on commit 2e23839

Please sign in to comment.