zova-module-a-logger 5.1.23 → 5.1.26

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/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 {\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,OAAA,CAAA,GAAA,UAAA,SAAA,EAER,QAAS,WACT,CAAA,GAAA,OAAS,WAAA,QAAA,WAAsB,MAAO,qBAAa,kBAAA;CACnD,IAAM,SAAG,MAAA,UAAmB,MAAM;EAClC,MAAS,UAAW,KAAK,YAAO,SAAc,QAAA;;EAI5C,MAAA,WAFe,KAAA,IAAA,KAAA,OAAqB,MAAQ,QAAA,WAAA,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AAA,KAAA,SAAA,OAAA;GACL,OAAS;EACT,SAAS,KAAA;GACT,KAAM,UAAO,UAAQ,SAAA,KAAA,SAAA,OAAA;GACrB,MAAQ;EACR;CACF;CACA,YAAQ,SAAU,UAAK;EACrB,OAAM,oBAAqB,QAAC,SAAA;GAC5B,MAAM;GACJ,KAAC,KAAA,QAAA,EAAA;GACD,KAAE,KAAQ,QAAQ,EAAC;GACnB,KAAK,KAAK,QAAQ,EAAE;EACtB,CAAC;CACH;CACA,UAAU,UAAU,SAAA,OAAA,SAAA,SAAA;EAClB,MAAA,OAAA;GACA,OAAM,QAAW;GACf;EACF;EACA,IAAE,SAAW,KAAK,UAAE;EACpB,KAAK,QAAM;EACX,SAAI,KAAO,IAAA;CACb;CACA,WAAU,UAAQ,SAAW,KAAM,SAAQ,SAAU;EACnD,MAAM,OAAE;GACN,OAAK,QAAA;GACL;EACF;EACA,IAAI,SAAS,KAAI,UAAA;EACjB,IAAI,QAAI,KAAA,GAAA,KAAA,SAAA;EACR,SAAE,KAAA,IAAA;CACJ;CACA,UAAU,UAAI,SAAA,KAAA,UAAA,SAAA;EACZ,MAAE,OAAW;GACX,OAAK;GACL;EACF;EACF,IAAA,SAAA,KAAA,UAAA;;EAEA,SAAW,KAAC,IAAQ;CACpB;AACF,CAAC,KAAK,QAAM,KAAA;;;;;AC/GZ,IAAG,MAAO,OAAA;AAcV,IAAC,sBAAA,OAAA,MAAA,GAAA,QAAA,SAAA,EACC,QAAM,WACR,CAAC,GAAG,KAAK,SAAM,MAAS,SAAC,MAAA,2BAAA,cAAA,CAAA,CAAA,KAAA,MAAA,KAAA;;;;;CCdzB,OAAO,aAAO,gBAAuB,OAAQ"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/bean/aopMethod.log.ts","../src/.metadata/index.ts","../src/lib/log.ts"],"sourcesContent":["var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\nimport { evaluateExpressions } from '@cabloy/utils';\nimport { BeanAopMethodBase, cast, SymbolBeanFullName } from 'zova';\nimport { AopMethod } from 'zova-module-a-bean';\nexport let AopMethodLog = (_dec = AopMethod({\n level: 'info'\n}), _dec2 = __z_BeanInfo({\n module: \"a-logger\"\n}), _dec(_class = _dec2(_class = class AopMethodLog extends BeanAopMethodBase {\n get(options, next, receiver, prop) {\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) {\n this._logError(profiler, context, err, options, message);\n throw err;\n }\n }\n set(options, value, next, receiver, prop) {\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) {\n this._logError(profiler, context, err, options, message);\n throw err;\n }\n }\n execute(options, _args, next, receiver, prop) {\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 = {\n level: options.level,\n message\n };\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.then(res => {\n options.result !== false && this._logResult(profiler, context, res, options, message);\n return res;\n }).catch(err => {\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) {\n this._logError(profiler, context, err, options, message);\n throw err;\n }\n }\n _getContext(options, receiver) {\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 _logValue(profiler, context, value, options, message) {\n const info = {\n level: options.level,\n message\n };\n if (context) info.context = context;\n info.value = value;\n profiler.done(info);\n }\n _logResult(profiler, context, res, options, message) {\n const info = {\n level: options.level,\n message\n };\n if (context) info.context = context;\n if (res !== undefined) info.result = res;\n profiler.done(info);\n }\n _logError(profiler, context, err, _options, message) {\n const info = {\n level: 'error',\n message\n };\n if (context) info.context = context;\n if (err) info.error = err;\n profiler.done(info);\n }\n}) || _class) || _class);","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\n// eslint-disable\n/** aopMethod: begin */\nexport * from '../bean/aopMethod.log.js';\nimport 'zova-module-a-bean';\n/** aopMethod: end */\n/** aopMethod: begin */\nimport { AopMethodLog } from '../bean/aopMethod.log.js';\nimport 'zova';\n/** aopMethod: end */\n/** scope: begin */\nimport { BeanScopeBase } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\nexport let ScopeModuleALogger = (_dec = Scope(), _dec2 = __z_BeanInfo({\n module: \"a-logger\"\n}), _dec(_class = _dec2(_class = class ScopeModuleALogger extends BeanScopeBase {}) || _class) || _class);\nimport 'zova';\n\n/** scope: end */","import { UseAopMethod } from 'zova-module-a-bean';\nexport function Log(options) {\n return UseAopMethod('a-logger:log', options);\n}"],"mappings":";;;;AAAA,IAAI,QAAM,SAAO;AAKjB,IAAW,gBAAgB,SAAO,UAAU,EAC1C,OAAO,OACT,CAAC,GAAG,UAAQ,SAAa,EACvB,QAAQ,WACV,CAAC,GAAG,OAAK,WAAS,QAAM,WAAS,MAAM,qBAAqB,kBAAkB;CAC5E,IAAI,SAAS,MAAM,UAAU,MAAM;EACjC,MAAM,UAAU,KAAK,YAAY,SAAS,QAAQ;EAClD,MAAM,UAAU,GAAG,SAAS,oBAAoB,GAAG,KAAK;EAGxD,MAAM,WAFS,KAAK,IAAI,KAAK,OAAO,MAAM,QAAQ,WAAW,QAAQ,UAEpD,CAAA,CAAO,WAAW;EAEnC,IAAI;GACF,MAAM,MAAM,KAAK;G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
2
  "name": "zova-module-a-logger",
3
- "version": "5.1.23",
4
- "gitHead": "3380f8c5d3989242b60dc2a34cbb330f74335cbe",
3
+ "version": "5.1.26",
4
+ "gitHead": "1a39e8008e1b48001cfeff475ddd53a2a0d867c4",
5
5
  "description": "",
6
6
  "keywords": [
7
7
  "Zova Module"
@@ -27,7 +27,7 @@
27
27
  "tsc:publish": "npm run clean && node ../../../../../packages-cli/cli/src/bin/zova.ts :bin:buildModule --sourcemap && tsc -p tsconfig.build.json",
28
28
  "prepublishOnly": "npm run tsc:publish",
29
29
  "prepack": "clean-package",
30
- "postpack": "clean-package restore && npm run clean"
30
+ "postpack": "clean-package restore"
31
31
  },
32
32
  "dependencies": {
33
33
  "@cabloy/logger": "^1.1.24"