simplejsble 1.2.1-dev90 → 1.2.1-dev94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -2,5 +2,6 @@ export { Adapter, type AdapterEvents } from './adapter';
2
2
  export { Backend } from './backend';
3
3
  export { Config, type DonglConfig, type SimpleBluezConfig, type WinRTConfig } from './config';
4
4
  export { SimpleBLEError, type ErrorCode } from './errors';
5
+ export { Logging, type LogEntry, type LogLevel } from './logging';
5
6
  export { LocalCharacteristic, LocalPeripheral, LocalService, type LocalCharacteristicEvents, type LocalPeripheralEvents, } from './local';
6
7
  export { Peripheral, type BluetoothAddressType, type Characteristic, type CharacteristicCapability, type Descriptor, type PeripheralEvents, type Service, } from './peripheral';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Peripheral = exports.LocalService = exports.LocalPeripheral = exports.LocalCharacteristic = exports.SimpleBLEError = exports.Config = exports.Backend = exports.Adapter = void 0;
3
+ exports.Peripheral = exports.LocalService = exports.LocalPeripheral = exports.LocalCharacteristic = exports.Logging = exports.SimpleBLEError = exports.Config = exports.Backend = exports.Adapter = void 0;
4
4
  const errors_1 = require("./errors");
5
5
  const handlers_1 = require("./handlers");
6
6
  const native_1 = require("./native");
@@ -39,6 +39,8 @@ var config_1 = require("./config");
39
39
  Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return config_1.Config; } });
40
40
  var errors_2 = require("./errors");
41
41
  Object.defineProperty(exports, "SimpleBLEError", { enumerable: true, get: function () { return errors_2.SimpleBLEError; } });
42
+ var logging_1 = require("./logging");
43
+ Object.defineProperty(exports, "Logging", { enumerable: true, get: function () { return logging_1.Logging; } });
42
44
  var local_1 = require("./local");
43
45
  Object.defineProperty(exports, "LocalCharacteristic", { enumerable: true, get: function () { return local_1.LocalCharacteristic; } });
44
46
  Object.defineProperty(exports, "LocalPeripheral", { enumerable: true, get: function () { return local_1.LocalPeripheral; } });
@@ -0,0 +1,22 @@
1
+ /** SimpleBLE's log levels, from 'none' (off) to the most detailed, 'verbose'. */
2
+ export type LogLevel = 'none' | 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'verbose';
3
+ /** One entry of SimpleBLE's log. */
4
+ export interface LogEntry {
5
+ readonly level: Exclude<LogLevel, 'none'>;
6
+ /** The component that logged it, such as `SimpleBLE` or `SimpleBLE->SimpleBluez`. */
7
+ readonly module: string;
8
+ readonly file: string;
9
+ readonly line: number;
10
+ readonly function: string;
11
+ readonly message: string;
12
+ }
13
+ /**
14
+ * SimpleBLE's log, process-wide. By default, entries up to 'info' go to
15
+ * standard output.
16
+ */
17
+ export declare const Logging: {
18
+ level: LogLevel;
19
+ setCallback(callback: ((entry: LogEntry) => void) | null): void;
20
+ logToStdout(): void;
21
+ logToFile(path?: string): void;
22
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Logging = void 0;
4
+ const native_1 = require("./native");
5
+ /**
6
+ * SimpleBLE's log, process-wide. By default, entries up to 'info' go to
7
+ * standard output.
8
+ */
9
+ exports.Logging = Object.freeze({
10
+ /** The most detailed level that is logged; 'none' turns logging off. */
11
+ get level() {
12
+ return native_1.native.loggingGetLevel();
13
+ },
14
+ set level(level) {
15
+ native_1.native.loggingSetLevel(level);
16
+ },
17
+ /**
18
+ * Delivers each entry to `callback` on the JavaScript thread, in the order
19
+ * they were logged, instead of writing it out. null discards entries.
20
+ */
21
+ setCallback(callback) {
22
+ if (callback === null) {
23
+ native_1.native.loggingSetCallback(null);
24
+ return;
25
+ }
26
+ if (typeof callback !== 'function')
27
+ throw new TypeError('callback must be a function or null');
28
+ native_1.native.loggingSetCallback(entry => callback(Object.freeze(entry)));
29
+ },
30
+ /** Writes entries to standard output, the default. */
31
+ logToStdout() {
32
+ native_1.native.loggingToStdout();
33
+ },
34
+ /** Appends entries to `path`, or to a new timestamped file in the working directory. */
35
+ logToFile(path) {
36
+ native_1.native.loggingToFile(path);
37
+ },
38
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simplejsble",
3
- "version": "1.2.1-dev90",
3
+ "version": "1.2.1-dev94",
4
4
  "description": "SimpleBLE for Node.js and Electron: a cross-platform Bluetooth Low Energy library",
5
5
  "keywords": [
6
6
  "bluetooth",