@logtape/logtape 0.1.0 → 0.1.1

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/esm/config.js CHANGED
@@ -6,6 +6,12 @@ import { getConsoleSink } from "./sink.js";
6
6
  * Whether the loggers are configured.
7
7
  */
8
8
  let configured = false;
9
+ /**
10
+ * Strong references to the loggers.
11
+ * This is to prevent the loggers from being garbage collected so that their
12
+ * sinks and filters are not removed.
13
+ */
14
+ const strongRefs = new Set();
9
15
  /**
10
16
  * Disposables to dispose when resetting the configuration.
11
17
  */
@@ -83,6 +89,7 @@ export function configure(config) {
83
89
  }
84
90
  logger.filters.push(toFilter(filter));
85
91
  }
92
+ strongRefs.add(logger);
86
93
  }
87
94
  for (const sink of Object.values(config.sinks)) {
88
95
  if (Symbol.dispose in sink)
@@ -117,6 +124,7 @@ export function configure(config) {
117
124
  export function reset() {
118
125
  dispose();
119
126
  LoggerImpl.getLogger([]).resetDescendants();
127
+ strongRefs.clear();
120
128
  configured = false;
121
129
  }
122
130
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logtape/logtape",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Simple logging library for Deno/Node.js/Bun/browsers",
5
5
  "keywords": [
6
6
  "logging",
package/script/config.js CHANGED
@@ -32,6 +32,12 @@ const sink_js_1 = require("./sink.js");
32
32
  * Whether the loggers are configured.
33
33
  */
34
34
  let configured = false;
35
+ /**
36
+ * Strong references to the loggers.
37
+ * This is to prevent the loggers from being garbage collected so that their
38
+ * sinks and filters are not removed.
39
+ */
40
+ const strongRefs = new Set();
35
41
  /**
36
42
  * Disposables to dispose when resetting the configuration.
37
43
  */
@@ -109,6 +115,7 @@ function configure(config) {
109
115
  }
110
116
  logger.filters.push((0, filter_js_1.toFilter)(filter));
111
117
  }
118
+ strongRefs.add(logger);
112
119
  }
113
120
  for (const sink of Object.values(config.sinks)) {
114
121
  if (Symbol.dispose in sink)
@@ -144,6 +151,7 @@ exports.configure = configure;
144
151
  function reset() {
145
152
  dispose();
146
153
  logger_js_1.LoggerImpl.getLogger([]).resetDescendants();
154
+ strongRefs.clear();
147
155
  configured = false;
148
156
  }
149
157
  exports.reset = reset;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAY,MAAM,aAAa,CAAC;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAkB,KAAK,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,MAAM,CAAC,OAAO,SAAS,MAAM,EAAE,SAAS,SAAS,MAAM;IACtE;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC7B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAEvC;;OAEG;IACH,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC;IAE5C;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY,CAC3B,OAAO,SAAS,MAAM,EACtB,SAAS,SAAS,MAAM;IAExB;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE5B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IAEtB;;;OAGG;IACH,KAAK,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CACzB;AAYD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,SAAS,CAAC,OAAO,SAAS,MAAM,EAAE,SAAS,SAAS,MAAM,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