Skip to content

Commit

Permalink
Merge 833792e into e1fe43a
Browse files Browse the repository at this point in the history
  • Loading branch information
kraenhansen committed Mar 27, 2024
2 parents e1fe43a + 833792e commit 4ec593b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 41 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* Improved performance of RQL queries on a non-linked string property using `>`, `>=`, `<`, `<=` operators and fixed behavior that a null string should be evaluated as less than everything, previously nulls were not matched. ([realm/realm-core#3939](https://github.com/realm/realm-core/issues/3939))
* Added support for using aggregate operations on Mixed properties in queries. ([realm/realm-core#7398](https://github.com/realm/realm-core/pull/7398))
* Improved file compaction performance on platforms with page sizes greater than 4k (for example arm64 Apple platforms) for files less than 256 pages in size. ([realm/realm-core#7492](https://github.com/realm/realm-core/pull/7492))
* Added the ability to pass a category as the second argument to `setLogLevel`. ([#6560](https://github.com/realm/realm-js/issues/6560))

### Fixed
* 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)
Expand Down
16 changes: 0 additions & 16 deletions packages/realm/src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,6 @@ export const LOG_CATEGORIES = [
*/
export type LogCategory = (typeof LOG_CATEGORIES)[number];

/**
* Log options to use when setting the log level.
*/
export type LogOptions = {
/**
* The log level to be used by the logger.
* @default "info"
*/
level: LogLevel;
/**
* The category to set the log level for. If omitted, the log level
* is set for all categories (`"Realm"`).
*/
category?: LogCategory;
};

/**
* A callback passed to `Realm.App.Sync.setLogger` when instrumenting the Atlas Device Sync client with a custom logger.
* @param level - The level of the log entry between 0 and 8 inclusively.
Expand Down
31 changes: 6 additions & 25 deletions packages/realm/src/Realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
List,
LogCategory,
LogLevel,
LogOptions,
LoggerCallback,
LoggerCallback1,
LoggerCallback2,
Expand Down Expand Up @@ -112,36 +111,18 @@ export class Realm {
private static internals = new Set<binding.WeakRef<binding.Realm>>();

/**
* Sets the log level across all levels.
* Sets the log level.
* @param level - The log level to be used by the logger. The default value is `info`.
* @param category - The category to set the log level for. If omitted, the log level is set for all categories (`"Realm"`).
* @note The log level can be changed during the lifetime of the application.
* @since 12.0.0
* @example
* Realm.setLogLevel("all");
*/
static setLogLevel(level: LogLevel): void;

/**
* Sets the log level for a specific category.
* @param options - The log options to use.
* @note The log level can be changed during the lifetime of the application.
* @since 12.7.0
* @example
* Realm.setLogLevel({ category: "Realm", level: "all" });
*/
static setLogLevel(options: LogOptions): void;
static setLogLevel(arg: LogLevel | LogOptions) {
const setLevel = (level: LogLevel, category = "Realm") => {
assert(LOG_CATEGORIES.includes(category as LogCategory), `Unexpected log category: '${category}'`);
const categoryRef = binding.LogCategoryRef.getCategory(category);
categoryRef.setDefaultLevelThreshold(toBindingLoggerLevel(level));
};

if (typeof arg === "string") {
setLevel(arg);
} else {
setLevel(arg.level, arg.category);
}
static setLogLevel(level: LogLevel, category: LogCategory = "Realm"): void {
assert(LOG_CATEGORIES.includes(category as LogCategory), `Unexpected log category: '${category}'`);
const categoryRef = binding.LogCategoryRef.getCategory(category);
categoryRef.setDefaultLevelThreshold(toBindingLoggerLevel(level));
}

/**
Expand Down

0 comments on commit 4ec593b

Please sign in to comment.