summaryrefslogtreecommitdiffstats
path: root/intl/icu_capi/js/package/lib/ICU4XLogger.js
blob: e696f7fd9b511841efcdc56f689098118c3ac13a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import wasm from "./diplomat-wasm.mjs"
import * as diplomatRuntime from "./diplomat-runtime.js"

const ICU4XLogger_box_destroy_registry = new FinalizationRegistry(underlying => {
  wasm.ICU4XLogger_destroy(underlying);
});

export class ICU4XLogger {
  #lifetimeEdges = [];
  constructor(underlying, owned, edges) {
    this.underlying = underlying;
    this.#lifetimeEdges.push(...edges);
    if (owned) {
      ICU4XLogger_box_destroy_registry.register(this, underlying);
    }
  }

  static init_simple_logger() {
    return wasm.ICU4XLogger_init_simple_logger();
  }

  static init_console_logger() {
    return wasm.ICU4XLogger_init_console_logger();
  }
}