zova-module-a-logger 5.1.9 → 5.1.10
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":"aopMethod.log.d.ts","sourceRoot":"","sources":["../../src/bean/aopMethod.log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACpF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"aopMethod.log.d.ts","sourceRoot":"","sources":["../../src/bean/aopMethod.log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACpF,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,0BAA0B,EAC3B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAA4B,MAAM,MAAM,CAAC;AAGnE,MAAM,WAAW,oBAAqB,SAAQ,0BAA0B;IACtE,KAAK,EAAE,WAAW,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,kBAAkB,CAAC;IACrC,UAAU,CAAC,EAAE,MAAM,mBAAmB,CAAC;IACvC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B;AAED,qBAGa,YACX,SAAQ,iBACR,YAAW,aAAa,EAAE,aAAa,EAAE,iBAAiB;IAE1D,GAAG,CAAC,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG;IAiBpF,GAAG,CACD,OAAO,EAAE,oBAAoB,EAC7B,KAAK,EAAE,GAAG,EACV,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,GAAG,EACb,IAAI,EAAE,MAAM,GACX,OAAO;IAiBV,OAAO,CACL,OAAO,EAAE,oBAAoB,EAC7B,KAAK,EAAE,EAAE,EACT,IAAI,EAAE,IAAI,GAAG,QAAQ,EACrB,QAAQ,EAAE,GAAG,EACb,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;IAkCrB,WAAW,CAAC,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,GAAG;IASxD,SAAS,CACP,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,GAAG,EACZ,KAAK,EAAE,GAAG,EACV,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,MAAM;IAQjB,UAAU,CACR,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,GAAG,EACZ,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,MAAM;IAQjB,SAAS,CACP,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,GAAG,EACZ,GAAG,EAAE,KAAK,EACV,QAAQ,EAAE,oBAAoB,EAC9B,OAAO,EAAE,MAAM;CAOlB"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/bean/aopMethod.log.ts","../src/.metadata/index.ts","../src/lib/log.ts"],"sourcesContent":["import type { ILoggerChildRecord, ILoggerClientRecord, Next, NextSync } from 'zova';\nimport type {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/bean/aopMethod.log.ts","../src/.metadata/index.ts","../src/lib/log.ts"],"sourcesContent":["import type { ILoggerChildRecord, ILoggerClientRecord, Next, NextSync } from 'zova';\nimport type {\n IAopMethodExecute,\n IAopMethodGet,\n IAopMethodSet,\n IDecoratorAopMethodOptions,\n} from 'zova-module-a-bean';\n\nimport { LoggerLevel, Profiler } from '@cabloy/logger';\nimport { evaluateExpressions } from '@cabloy/utils';\nimport { BeanAopMethodBase, cast, SymbolBeanFullName } from 'zova';\nimport { AopMethod } from 'zova-module-a-bean';\n\nexport interface IAopMethodOptionsLog extends IDecoratorAopMethodOptions {\n level: LoggerLevel;\n childName?: keyof ILoggerChildRecord;\n clientName?: keyof ILoggerClientRecord;\n args?: boolean;\n result?: boolean;\n context?: Record<string, any>;\n}\n\n@AopMethod<IAopMethodOptionsLog>({\n level: 'info',\n})\nexport class AopMethodLog\n extends BeanAopMethodBase\n implements IAopMethodGet, IAopMethodSet, IAopMethodExecute\n{\n get(options: IAopMethodOptionsLog, next: NextSync, receiver: any, prop: string): any {\n const context = this._getContext(options, receiver);\n const message = `${receiver[SymbolBeanFullName]}#${prop}(get)`;\n const logger = this.sys.meta.logger.child(options.childName, options.clientName);\n // begin\n const profiler = logger.startTimer();\n // next\n try {\n const res = next();\n this._logResult(profiler, context, res, options, message);\n return res;\n } catch (err: any) {\n this._logError(profiler, context, err, options, message);\n throw err;\n }\n }\n\n set(\n options: IAopMethodOptionsLog,\n value: any,\n next: NextSync,\n receiver: any,\n prop: string,\n ): boolean {\n const context = this._getContext(options, receiver);\n const message = `${receiver[SymbolBeanFullName]}#${prop}(set)`;\n const logger = this.sys.meta.logger.child(options.childName, options.clientName);\n // begin\n const profiler = logger.startTimer();\n // next\n try {\n const res = next();\n this._logValue(profiler, context, value, options, message);\n return res;\n } catch (err: any) {\n this._logError(profiler, context, err, options, message);\n throw err;\n }\n }\n\n execute(\n options: IAopMethodOptionsLog,\n _args: [],\n next: Next | NextSync,\n receiver: any,\n prop: string,\n ): Promise<any> | any {\n const context = this._getContext(options, receiver);\n const message = `${receiver[SymbolBeanFullName]}#${prop}`;\n const logger = this.sys.meta.logger.child(options.childName, options.clientName);\n // begin\n if (options.args !== false) {\n const info: any = { level: options.level, message };\n if (context) info.context = context;\n if (_args.length > 0) info.args = _args;\n logger.log(info);\n }\n const profiler = logger.startTimer();\n // next\n try {\n const res = next();\n if (res?.then) {\n return res\n .then((res: any) => {\n options.result !== false && this._logResult(profiler, context, res, options, message);\n return res;\n })\n .catch((err: Error) => {\n this._logError(profiler, context, err, options, message);\n throw err;\n });\n }\n options.result !== false && this._logResult(profiler, context, res, options, message);\n return res;\n } catch (err: any) {\n this._logError(profiler, context, err, options, message);\n throw err;\n }\n }\n\n _getContext(options: IAopMethodOptionsLog, receiver: any) {\n return evaluateExpressions(options.context, {\n self: receiver,\n sys: cast(receiver).sys,\n app: cast(receiver).app,\n ctx: cast(receiver).ctx,\n });\n }\n\n _logValue(\n profiler: Profiler,\n context: any,\n value: any,\n options: IAopMethodOptionsLog,\n message: string,\n ) {\n const info: any = { level: options.level, message };\n if (context) info.context = context;\n info.value = value;\n profiler.done(info);\n }\n\n _logResult(\n profiler: Profiler,\n context: any,\n res: any,\n options: IAopMethodOptionsLog,\n message: string,\n ) {\n const info: any = { level: options.level, message };\n if (context) info.context = context;\n if (res !== undefined) info.result = res;\n profiler.done(info);\n }\n\n _logError(\n profiler: Profiler,\n context: any,\n err: Error,\n _options: IAopMethodOptionsLog,\n message: string,\n ) {\n const info: any = { level: 'error', message };\n if (context) info.context = context;\n if (err) info.error = err;\n profiler.done(info);\n }\n}\n","// eslint-disable\n/** aopMethod: begin */\nexport * from '../bean/aopMethod.log.js';\nimport { IAopMethodOptionsLog } from '../bean/aopMethod.log.js';\nimport 'zova-module-a-bean';\ndeclare module 'zova-module-a-bean' {\n \n export interface IAopMethodRecord {\n 'a-logger:log': IAopMethodOptionsLog;\n }\n\n \n}\ndeclare module 'zova-module-a-logger' {\n \n export interface AopMethodLog {\n /** @internal */\n get scope(): ScopeModuleALogger;\n }\n\n export interface AopMethodLog {\n get $beanFullName(): 'a-logger.aopMethod.log';\n get $onionName(): 'a-logger:log';\n get $onionOptions(): IAopMethodOptionsLog;\n } \n}\n/** aopMethod: end */\n/** aopMethod: begin */\nimport { AopMethodLog } from '../bean/aopMethod.log.js';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordLocal {\n 'a-logger.aopMethod.log': AopMethodLog;\n }\n}\n/** aopMethod: end */\n/** scope: begin */\nimport { BeanScopeBase, type BeanScopeUtil } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\n\n@Scope()\nexport class ScopeModuleALogger extends BeanScopeBase {}\n\nexport interface ScopeModuleALogger {\n util: BeanScopeUtil;\n}\n\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanScopeRecord {\n 'a-logger': ScopeModuleALogger;\n }\n \n \n\n \n\n \n}\n \n/** scope: end */\n","import { UseAopMethod } from 'zova-module-a-bean';\n\nimport type { IAopMethodOptionsLog } from '../bean/aopMethod.log.js';\n\nexport function Log(options?: Partial<IAopMethodOptionsLog>): MethodDecorator {\n return UseAopMethod('a-logger:log', options);\n}\n"],"mappings":";;;;AAAA,IAAA,QAAO,SAAO;AAKd,IAAE,gBAAA,SAA0B,UAAA,EAC1B,OAAM,QAAA,CAAA,EAAA,UAAA,SAAA,EAER,QAAS,YACT,CAAA,EAAA,OAAS,WAAA,QAAA,WAAsB,MAAO,qBAAa,kBAAA;CACnD,IAAM,SAAG,MAAA,UAAmB,MAAM;EAClC,MAAS,UAAW,KAAK,YAAO,SAAc,SAAA;;EAI5C,MAAA,WAFe,KAAA,IAAA,KAAA,OAAqB,MAAQ,QAAA,WAAA,QAA2B,WAAA,CAErD,YAAkB;AAEpC,MAAM;GACN,MAAS,MAAO,MAAA;AAChB,QAAS,WAAQ,UAAY,SAAA,KAAA,SAAA,QAAA;AAC/B,UAAA;;AAEC,QAAU,UAAA,UAAoB,SAAE,KAAA,SAAA,QAAA;AAC/B,SAAQ;;;CAGR,IAAA,SAAQ,OAAA,MAAA,UAAA,MAAA;EACR,MAAA,UAAW,KAAA,YAAe,SAAe,SAAA;EAC3C,MAAA,UAAA,GAAA,SAAA,oBAAA,GAAA,KAAA;EAGI,MAAM,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,MAAE,QAAW,MAAK,UAAE;AACpB,OAAK,QAAM;AACX,WAAI,KAAO,KAAA;;CAEb,WAAU,UAAQ,SAAW,KAAM,SAAQ,SAAU;EACnD,MAAM,OAAE;GACN,OAAK,QAAA;GACL;GACD;AACD,MAAI,QAAS,MAAI,UAAA;AACjB,MAAI,QAAI,KAAA,EAAA,MAAA,SAAA;AACR,WAAE,KAAA,KAAA;;CAEJ,UAAU,UAAI,SAAA,KAAA,UAAA,SAAA;EACZ,MAAE,OAAW;GACX,OAAK;GACL;GACF;AACF,MAAA,QAAA,MAAA,UAAA;;AAEA,WAAW,KAAC,KAAS;;EAErB,IAAI,SAAM,IAAA;;;;;AC/GZ,IAAG,MAAO,OAAA;AAcV,IAAC,sBAAA,OAAA,OAAA,EAAA,QAAA,SAAA,EACC,QAAM,YACP,CAAC,EAAE,KAAK,SAAM,MAAS,SAAC,MAAA,2BAAA,cAAA,GAAA,IAAA,OAAA,IAAA;;;;;ACdzB,QAAO,aAAO,gBAAuB,QAAS"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zova-module-a-logger",
|
|
3
|
-
"version": "5.1.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "5.1.10",
|
|
4
|
+
"gitHead": "a247f88a55c663d313296039f874560ee5a13e01",
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Zova Module"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"postpack": "clean-package restore && npm run clean"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@cabloy/logger": "^1.1.
|
|
34
|
+
"@cabloy/logger": "^1.1.10"
|
|
35
35
|
},
|
|
36
36
|
"title": "a-logger",
|
|
37
37
|
"zovaModule": {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { ILoggerChildRecord, ILoggerClientRecord, Next, NextSync } from 'zova';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
IAopMethodExecute,
|
|
4
|
+
IAopMethodGet,
|
|
5
|
+
IAopMethodSet,
|
|
6
|
+
IDecoratorAopMethodOptions,
|
|
7
|
+
} from 'zova-module-a-bean';
|
|
3
8
|
|
|
4
9
|
import { LoggerLevel, Profiler } from '@cabloy/logger';
|
|
5
10
|
import { evaluateExpressions } from '@cabloy/utils';
|
|
@@ -18,7 +23,10 @@ export interface IAopMethodOptionsLog extends IDecoratorAopMethodOptions {
|
|
|
18
23
|
@AopMethod<IAopMethodOptionsLog>({
|
|
19
24
|
level: 'info',
|
|
20
25
|
})
|
|
21
|
-
export class AopMethodLog
|
|
26
|
+
export class AopMethodLog
|
|
27
|
+
extends BeanAopMethodBase
|
|
28
|
+
implements IAopMethodGet, IAopMethodSet, IAopMethodExecute
|
|
29
|
+
{
|
|
22
30
|
get(options: IAopMethodOptionsLog, next: NextSync, receiver: any, prop: string): any {
|
|
23
31
|
const context = this._getContext(options, receiver);
|
|
24
32
|
const message = `${receiver[SymbolBeanFullName]}#${prop}(get)`;
|
|
@@ -36,7 +44,13 @@ export class AopMethodLog extends BeanAopMethodBase implements IAopMethodGet, IA
|
|
|
36
44
|
}
|
|
37
45
|
}
|
|
38
46
|
|
|
39
|
-
set(
|
|
47
|
+
set(
|
|
48
|
+
options: IAopMethodOptionsLog,
|
|
49
|
+
value: any,
|
|
50
|
+
next: NextSync,
|
|
51
|
+
receiver: any,
|
|
52
|
+
prop: string,
|
|
53
|
+
): boolean {
|
|
40
54
|
const context = this._getContext(options, receiver);
|
|
41
55
|
const message = `${receiver[SymbolBeanFullName]}#${prop}(set)`;
|
|
42
56
|
const logger = this.sys.meta.logger.child(options.childName, options.clientName);
|
|
@@ -53,7 +67,13 @@ export class AopMethodLog extends BeanAopMethodBase implements IAopMethodGet, IA
|
|
|
53
67
|
}
|
|
54
68
|
}
|
|
55
69
|
|
|
56
|
-
execute(
|
|
70
|
+
execute(
|
|
71
|
+
options: IAopMethodOptionsLog,
|
|
72
|
+
_args: [],
|
|
73
|
+
next: Next | NextSync,
|
|
74
|
+
receiver: any,
|
|
75
|
+
prop: string,
|
|
76
|
+
): Promise<any> | any {
|
|
57
77
|
const context = this._getContext(options, receiver);
|
|
58
78
|
const message = `${receiver[SymbolBeanFullName]}#${prop}`;
|
|
59
79
|
const logger = this.sys.meta.logger.child(options.childName, options.clientName);
|
|
@@ -88,24 +108,47 @@ export class AopMethodLog extends BeanAopMethodBase implements IAopMethodGet, IA
|
|
|
88
108
|
}
|
|
89
109
|
|
|
90
110
|
_getContext(options: IAopMethodOptionsLog, receiver: any) {
|
|
91
|
-
return evaluateExpressions(options.context, {
|
|
111
|
+
return evaluateExpressions(options.context, {
|
|
112
|
+
self: receiver,
|
|
113
|
+
sys: cast(receiver).sys,
|
|
114
|
+
app: cast(receiver).app,
|
|
115
|
+
ctx: cast(receiver).ctx,
|
|
116
|
+
});
|
|
92
117
|
}
|
|
93
118
|
|
|
94
|
-
_logValue(
|
|
119
|
+
_logValue(
|
|
120
|
+
profiler: Profiler,
|
|
121
|
+
context: any,
|
|
122
|
+
value: any,
|
|
123
|
+
options: IAopMethodOptionsLog,
|
|
124
|
+
message: string,
|
|
125
|
+
) {
|
|
95
126
|
const info: any = { level: options.level, message };
|
|
96
127
|
if (context) info.context = context;
|
|
97
128
|
info.value = value;
|
|
98
129
|
profiler.done(info);
|
|
99
130
|
}
|
|
100
131
|
|
|
101
|
-
_logResult(
|
|
132
|
+
_logResult(
|
|
133
|
+
profiler: Profiler,
|
|
134
|
+
context: any,
|
|
135
|
+
res: any,
|
|
136
|
+
options: IAopMethodOptionsLog,
|
|
137
|
+
message: string,
|
|
138
|
+
) {
|
|
102
139
|
const info: any = { level: options.level, message };
|
|
103
140
|
if (context) info.context = context;
|
|
104
141
|
if (res !== undefined) info.result = res;
|
|
105
142
|
profiler.done(info);
|
|
106
143
|
}
|
|
107
144
|
|
|
108
|
-
_logError(
|
|
145
|
+
_logError(
|
|
146
|
+
profiler: Profiler,
|
|
147
|
+
context: any,
|
|
148
|
+
err: Error,
|
|
149
|
+
_options: IAopMethodOptionsLog,
|
|
150
|
+
message: string,
|
|
151
|
+
) {
|
|
109
152
|
const info: any = { level: 'error', message };
|
|
110
153
|
if (context) info.context = context;
|
|
111
154
|
if (err) info.error = err;
|