@idlebox/logger 0.0.14 → 0.0.16

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.
@@ -1 +1 @@
1
- {"version":3,"file":"logger.global.d.ts","sourceRoot":"","sources":["../../src/common/logger.global.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAM5D;;GAEG;AACH,eAAO,IAAI,QAAQ,EAAE,SAAS,CAAC;AAE/B;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,GAAE,cAAoC,GAAG,IAAI,CAaxG"}
1
+ {"version":3,"file":"logger.global.d.ts","sourceRoot":"","sources":["../../src/common/logger.global.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAQ5D;;GAEG;AACH,eAAO,IAAI,QAAQ,EAAE,SAAS,CAAC;AAE/B;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,GAAE,cAAoC,GAAG,IAAI,CAkBxG"}
@@ -1,3 +1,4 @@
1
+ import { globalObject } from '@idlebox/common';
1
2
  import process from 'node:process';
2
3
  import { PassThrough } from 'node:stream';
3
4
  import { create } from './create.logger.js';
@@ -5,6 +6,7 @@ import { EnableLogLevel } from './types.js';
5
6
  const stream = new PassThrough();
6
7
  stream.pipe(process.stderr);
7
8
  Object.assign(stream, { isTTY: process.stderr.isTTY });
9
+ const symbol = Symbol.for('@idlebox/logger/global/terminal');
8
10
  /**
9
11
  * 作为logger导出,必须在程序入口调用过 createGlobalLogger() 才能使用
10
12
  */
@@ -13,9 +15,13 @@ export let terminal;
13
15
  * 创建root-logger,随后logger变量可用
14
16
  */
15
17
  export function createGlobalLogger(tag, defaultLevel = EnableLogLevel.auto) {
16
- if (terminal)
17
- throw new Error('global logger already created');
18
+ terminal = globalObject[symbol];
19
+ if (terminal) {
20
+ terminal.error `global logger already created`;
21
+ return;
22
+ }
18
23
  terminal = create(tag, undefined, stream);
24
+ globalObject[symbol] = terminal;
19
25
  terminal.enable(defaultLevel || EnableLogLevel.log);
20
26
  if (terminal.verbose.isEnabled) {
21
27
  terminal.verbose `verbose is enabled`;
@@ -1 +1 @@
1
- {"version":3,"file":"logger.global.js","sourceRoot":"","sources":["../../src/common/logger.global.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAkB,MAAM,YAAY,CAAC;AAE5D,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;AACjC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAC5B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;AAEvD;;GAEG;AACH,MAAM,CAAC,IAAI,QAAmB,CAAC;AAE/B;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW,EAAE,eAA+B,cAAc,CAAC,IAAI;IACjG,IAAI,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAE/D,QAAQ,GAAG,MAAM,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAE1C,QAAQ,CAAC,MAAM,CAAC,YAAY,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC;IAEpD,IAAI,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QAChC,QAAQ,CAAC,OAAO,CAAA,oBAAoB,CAAC;IACtC,CAAC;SAAM,CAAC;QACP,QAAQ,CAAC,KAAK,CAAA,kBAAkB,CAAC;IAClC,CAAC;I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,QAAQ,CAAC,KAAK,CAAA,kBAAkB,CAAC;IAClC,CAAC;IACD,OAAO;AACR,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@idlebox/logger",
3
3
  "type": "module",
4
- "version": "0.0.14",
4
+ "version": "0.0.16",
5
5
  "description": "A simple logger module for my self use (nodejs).",
6
6
  "exports": {
7
7
  ".": {
@@ -13,12 +13,12 @@
13
13
  "sideEffects": false,
14
14
  "dependencies": {
15
15
  "debug": "^4.4.3",
16
- "@idlebox/common": "^1.5.11"
16
+ "@idlebox/common": "^1.5.13"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/debug": "^4.1.12",
20
20
  "@types/node": "^25.0.8",
21
- "@build-script/single-dog-asset": "latest",
21
+ "@build-script/baseline-rig": "latest",
22
22
  "@mpis/run": "^0.0.17"
23
23
  },
24
24
  "license": "MIT",
@@ -1,3 +1,4 @@
1
+ import { globalObject } from '@idlebox/common';
1
2
  import process from 'node:process';
2
3
  import { PassThrough } from 'node:stream';
3
4
  import { create } from './create.logger.js';
@@ -7,6 +8,8 @@ const stream = new PassThrough();
7
8
  stream.pipe(process.stderr);
8
9
  Object.assign(stream, { isTTY: process.stderr.isTTY });
9
10
 
11
+ const symbol = Symbol.for('@idlebox/logger/global/terminal');
12
+
10
13
  /**
11
14
  * 作为logger导出,必须在程序入口调用过 createGlobalLogger() 才能使用
12
15
  */
@@ -16,9 +19,14 @@ export let terminal: IMyLogger;
16
19
  * 创建root-logger,随后logger变量可用
17
20
  */
18
21
  export function createGlobalLogger(tag: string, defaultLevel: EnableLogLevel = EnableLogLevel.auto): void {
19
- if (terminal) throw new Error('global logger already created');
22
+ terminal = globalObject[symbol];
23
+ if (terminal) {
24
+ terminal.error`global logger already created`;
25
+ return;
26
+ }
20
27
 
21
28
  terminal = create(tag, undefined, stream);
29
+ globalObject[symbol] = terminal;
22
30
 
23
31
  terminal.enable(defaultLevel || EnableLogLevel.log);
24
32
 
package/src/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "@build-script/single-dog-asset/package/tsconfig.json",
2
+ "extends": "@build-script/baseline-rig/package/tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "typeRoots": ["../node_modules/@types", "../node_modules"],
5
5
  "outDir": "../lib",