@simplysm/core-common 14.0.77 → 14.0.79
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.
|
@@ -4,6 +4,9 @@ import { type ConsolaInstance } from "consola";
|
|
|
4
4
|
* consola.withTag() 직접 호출은 호출 시점의 consola.options(level/reporters)를 스냅샷으로 굳혀
|
|
5
5
|
* 이후 setupConsola() 변경이 child 인스턴스에 반영되지 않는다.
|
|
6
6
|
* createLogger 는 첫 메서드 접근 시점까지 withTag 생성을 지연한다.
|
|
7
|
+
*
|
|
8
|
+
* Proxy trap 보강 — vi.spyOn 호환을 위해 has/getOwnPropertyDescriptor 처리하고
|
|
9
|
+
* target 에 직접 설치된 property(=spy)를 cached 보다 우선 반환한다.
|
|
7
10
|
*/
|
|
8
11
|
export declare function createLogger(tag: string): ConsolaInstance;
|
|
9
12
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/features/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAExD
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/features/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAExD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAuBzD"}
|
package/dist/features/logger.js
CHANGED
|
@@ -4,14 +4,31 @@ import { consola } from "consola";
|
|
|
4
4
|
* consola.withTag() 직접 호출은 호출 시점의 consola.options(level/reporters)를 스냅샷으로 굳혀
|
|
5
5
|
* 이후 setupConsola() 변경이 child 인스턴스에 반영되지 않는다.
|
|
6
6
|
* createLogger 는 첫 메서드 접근 시점까지 withTag 생성을 지연한다.
|
|
7
|
+
*
|
|
8
|
+
* Proxy trap 보강 — vi.spyOn 호환을 위해 has/getOwnPropertyDescriptor 처리하고
|
|
9
|
+
* target 에 직접 설치된 property(=spy)를 cached 보다 우선 반환한다.
|
|
7
10
|
*/
|
|
8
11
|
export function createLogger(tag) {
|
|
9
12
|
let cached;
|
|
13
|
+
const ensure = () => (cached ??= consola.withTag(tag));
|
|
10
14
|
return new Proxy({}, {
|
|
11
|
-
get(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
get(target, prop, receiver) {
|
|
16
|
+
if (Reflect.has(target, prop)) {
|
|
17
|
+
return Reflect.get(target, prop, receiver);
|
|
18
|
+
}
|
|
19
|
+
const c = ensure();
|
|
20
|
+
const value = Reflect.get(c, prop);
|
|
21
|
+
return typeof value === "function" ? value.bind(c) : value;
|
|
22
|
+
},
|
|
23
|
+
has(target, prop) {
|
|
24
|
+
return Reflect.has(target, prop) || Reflect.has(ensure(), prop);
|
|
25
|
+
},
|
|
26
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
27
|
+
if (Reflect.has(target, prop)) {
|
|
28
|
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
29
|
+
}
|
|
30
|
+
const desc = Reflect.getOwnPropertyDescriptor(ensure(), prop);
|
|
31
|
+
return desc != null ? { ...desc, configurable: true } : undefined;
|
|
15
32
|
},
|
|
16
33
|
});
|
|
17
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/features/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAwB,MAAM,SAAS,CAAC;AAExD
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/features/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAwB,MAAM,SAAS,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,IAAI,MAAmC,CAAC;IACxC,MAAM,MAAM,GAAG,GAAoB,EAA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logger.ts
CHANGED
|
@@ -5,14 +5,31 @@ import { consola, type ConsolaInstance } from "consola";
|
|
|
5
5
|
* consola.withTag() 직접 호출은 호출 시점의 consola.options(level/reporters)를 스냅샷으로 굳혀
|
|
6
6
|
* 이후 setupConsola() 변경이 child 인스턴스에 반영되지 않는다.
|
|
7
7
|
* createLogger 는 첫 메서드 접근 시점까지 withTag 생성을 지연한다.
|
|
8
|
+
*
|
|
9
|
+
* Proxy trap 보강 — vi.spyOn 호환을 위해 has/getOwnPropertyDescriptor 처리하고
|
|
10
|
+
* target 에 직접 설치된 property(=spy)를 cached 보다 우선 반환한다.
|
|
8
11
|
*/
|
|
9
12
|
export function createLogger(tag: string): ConsolaInstance {
|
|
10
13
|
let cached: ConsolaInstance | undefined;
|
|
14
|
+
const ensure = (): ConsolaInstance => (cached ??= consola.withTag(tag));
|
|
11
15
|
return new Proxy({} as ConsolaInstance, {
|
|
12
|
-
get(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
get(target, prop, receiver) {
|
|
17
|
+
if (Reflect.has(target, prop)) {
|
|
18
|
+
return Reflect.get(target, prop, receiver);
|
|
19
|
+
}
|
|
20
|
+
const c = ensure();
|
|
21
|
+
const value: unknown = Reflect.get(c, prop);
|
|
22
|
+
return typeof value === "function" ? value.bind(c) : value;
|
|
23
|
+
},
|
|
24
|
+
has(target, prop) {
|
|
25
|
+
return Reflect.has(target, prop) || Reflect.has(ensure(), prop);
|
|
26
|
+
},
|
|
27
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
28
|
+
if (Reflect.has(target, prop)) {
|
|
29
|
+
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
30
|
+
}
|
|
31
|
+
const desc = Reflect.getOwnPropertyDescriptor(ensure(), prop);
|
|
32
|
+
return desc != null ? { ...desc, configurable: true } : undefined;
|
|
16
33
|
},
|
|
17
34
|
});
|
|
18
35
|
}
|