vona-module-a-logger 5.0.11 → 5.0.13
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/.metadata/index.d.ts +28 -29
- package/dist/bean/aopMethod.log.d.ts +1 -1
- package/dist/index.js +43 -41
- package/package.json +1 -1
|
@@ -1,24 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { IAopMethodOptionsLog } from '../bean/aopMethod.log.ts';
|
|
4
|
-
/** bean: end */
|
|
5
|
-
/** bean: begin */
|
|
6
|
-
import type { BeanLogger } from '../bean/bean.logger.ts';
|
|
7
|
-
/** broadcast: end */
|
|
8
|
-
/** broadcast: begin */
|
|
9
|
-
import type { BroadcastSetLevel } from '../bean/broadcast.setLevel.ts';
|
|
10
|
-
/** middlewareSystem: end */
|
|
11
|
-
/** aopMethod: begin */
|
|
1
|
+
/** middlewareSystem: begin */
|
|
2
|
+
export * from '../bean/middlewareSystem.httpLog.ts';
|
|
12
3
|
import type { IMiddlewareSystemOptionsHttpLog } from '../bean/middlewareSystem.httpLog.ts';
|
|
13
|
-
/** broadcast: end */
|
|
14
|
-
/** scope: begin */
|
|
15
|
-
import { BeanScopeBase } from 'vona';
|
|
16
|
-
import 'vona';
|
|
17
|
-
import 'vona';
|
|
18
4
|
import 'vona';
|
|
19
|
-
import 'vona';
|
|
20
|
-
import 'vona';
|
|
21
|
-
export * from '../bean/aopMethod.log.ts';
|
|
22
5
|
declare module 'vona-module-a-aspect' {
|
|
23
6
|
interface IMiddlewareSystemRecord {
|
|
24
7
|
'a-logger:httpLog': IMiddlewareSystemOptionsHttpLog;
|
|
@@ -28,9 +11,11 @@ declare module 'vona-module-a-logger' {
|
|
|
28
11
|
interface MiddlewareSystemHttpLog {
|
|
29
12
|
}
|
|
30
13
|
}
|
|
31
|
-
/**
|
|
32
|
-
/**
|
|
33
|
-
export * from '../bean/
|
|
14
|
+
/** middlewareSystem: end */
|
|
15
|
+
/** aopMethod: begin */
|
|
16
|
+
export * from '../bean/aopMethod.log.ts';
|
|
17
|
+
import type { IAopMethodOptionsLog } from '../bean/aopMethod.log.ts';
|
|
18
|
+
import 'vona';
|
|
34
19
|
declare module 'vona-module-a-aspect' {
|
|
35
20
|
interface IAopMethodRecord {
|
|
36
21
|
'a-logger:log': IAopMethodOptionsLog;
|
|
@@ -40,22 +25,29 @@ declare module 'vona-module-a-logger' {
|
|
|
40
25
|
interface AopMethodLog {
|
|
41
26
|
}
|
|
42
27
|
}
|
|
43
|
-
/**
|
|
44
|
-
/**
|
|
45
|
-
export * from '../bean/
|
|
28
|
+
/** aopMethod: end */
|
|
29
|
+
/** bean: begin */
|
|
30
|
+
export * from '../bean/bean.logger.ts';
|
|
31
|
+
import 'vona';
|
|
46
32
|
declare module 'vona' {
|
|
47
33
|
}
|
|
48
34
|
declare module 'vona-module-a-logger' {
|
|
49
35
|
interface BeanLogger {
|
|
50
36
|
}
|
|
51
37
|
}
|
|
38
|
+
/** bean: end */
|
|
39
|
+
/** bean: begin */
|
|
40
|
+
import type { BeanLogger } from '../bean/bean.logger.ts';
|
|
41
|
+
import 'vona';
|
|
52
42
|
declare module 'vona' {
|
|
53
43
|
interface IBeanRecordGlobal {
|
|
54
|
-
logger: BeanLogger;
|
|
44
|
+
'logger': BeanLogger;
|
|
55
45
|
}
|
|
56
46
|
}
|
|
57
|
-
/**
|
|
58
|
-
|
|
47
|
+
/** bean: end */
|
|
48
|
+
/** broadcast: begin */
|
|
49
|
+
export * from '../bean/broadcast.setLevel.ts';
|
|
50
|
+
import { type IDecoratorBroadcastOptions } from 'vona-module-a-broadcast';
|
|
59
51
|
declare module 'vona-module-a-broadcast' {
|
|
60
52
|
interface IBroadcastRecord {
|
|
61
53
|
'a-logger:setLevel': IDecoratorBroadcastOptions;
|
|
@@ -65,15 +57,22 @@ declare module 'vona-module-a-logger' {
|
|
|
65
57
|
interface BroadcastSetLevel {
|
|
66
58
|
}
|
|
67
59
|
}
|
|
60
|
+
/** broadcast: end */
|
|
61
|
+
/** broadcast: begin */
|
|
62
|
+
import type { BroadcastSetLevel } from '../bean/broadcast.setLevel.ts';
|
|
68
63
|
export interface IModuleBroadcast {
|
|
69
|
-
setLevel: BroadcastSetLevel;
|
|
64
|
+
'setLevel': BroadcastSetLevel;
|
|
70
65
|
}
|
|
66
|
+
/** broadcast: end */
|
|
67
|
+
/** scope: begin */
|
|
68
|
+
import { BeanScopeBase, type BeanScopeUtil } from 'vona';
|
|
71
69
|
export declare class ScopeModuleALogger extends BeanScopeBase {
|
|
72
70
|
}
|
|
73
71
|
export interface ScopeModuleALogger {
|
|
74
72
|
util: BeanScopeUtil;
|
|
75
73
|
broadcast: IModuleBroadcast;
|
|
76
74
|
}
|
|
75
|
+
import 'vona';
|
|
77
76
|
declare module 'vona' {
|
|
78
77
|
interface IBeanScopeRecord {
|
|
79
78
|
'a-logger': ScopeModuleALogger;
|
|
@@ -15,7 +15,7 @@ export declare class AopMethodLog extends BeanAopMethodBase implements IAopMetho
|
|
|
15
15
|
get(options: IAopMethodOptionsLog, next: NextSync, receiver: any, prop: string): any;
|
|
16
16
|
set(options: IAopMethodOptionsLog, value: any, next: NextSync, receiver: any, prop: string): boolean;
|
|
17
17
|
execute(options: IAopMethodOptionsLog, _args: [], next: Next | NextSync, receiver: any, prop: string): Promise<any> | any;
|
|
18
|
-
_getContext(options: IAopMethodOptionsLog, receiver: any):
|
|
18
|
+
_getContext(options: IAopMethodOptionsLog, receiver: any): any;
|
|
19
19
|
_logResult(profiler: winston.Profiler, context: any, res: any, options: IAopMethodOptionsLog, message: string): void;
|
|
20
20
|
_logError(profiler: winston.Profiler, context: any, err: Error, _options: IAopMethodOptionsLog, message: string): void;
|
|
21
21
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,41 @@
|
|
|
1
|
-
import { BeanInfo, BeanAopMethodBase, SymbolBeanFullName,
|
|
2
|
-
import
|
|
1
|
+
import { BeanInfo, BeanBase, BeanAopMethodBase, SymbolBeanFullName, BeanScopeBase } from 'vona';
|
|
2
|
+
import StdSerializers from 'pino-std-serializers';
|
|
3
|
+
import { MiddlewareSystem, AopMethod, Aspect } from 'vona-module-a-aspect';
|
|
3
4
|
import { evaluateExpressions } from '@cabloy/utils';
|
|
4
|
-
import {
|
|
5
|
+
import { Bean, Scope } from 'vona-module-a-bean';
|
|
5
6
|
import { Broadcast, BeanBroadcastBase } from 'vona-module-a-broadcast';
|
|
6
|
-
import StdSerializers from 'pino-std-serializers';
|
|
7
7
|
|
|
8
8
|
var _dec$4, _dec2$4, _class$4;
|
|
9
|
-
let
|
|
9
|
+
let MiddlewareSystemHttpLog = (_dec$4 = MiddlewareSystem(), _dec2$4 = BeanInfo({
|
|
10
|
+
module: "a-logger"
|
|
11
|
+
}), _dec$4(_class$4 = _dec2$4(_class$4 = class MiddlewareSystemHttpLog extends BeanBase {
|
|
12
|
+
async execute(_options, next) {
|
|
13
|
+
const ctx = this.ctx;
|
|
14
|
+
// start
|
|
15
|
+
const req = StdSerializers.req(ctx.req);
|
|
16
|
+
this.$loggerChild('req').http(JSON.stringify(req));
|
|
17
|
+
const profiler = this.$loggerChild('res').startTimer();
|
|
18
|
+
// next
|
|
19
|
+
await next();
|
|
20
|
+
// end
|
|
21
|
+
const res = {
|
|
22
|
+
url: ctx.req.url,
|
|
23
|
+
statusCode: ctx.res.statusCode,
|
|
24
|
+
headers: ctx.res.getHeaders()
|
|
25
|
+
};
|
|
26
|
+
profiler.done({
|
|
27
|
+
level: 'http',
|
|
28
|
+
message: JSON.stringify(res)
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}) || _class$4) || _class$4);
|
|
32
|
+
|
|
33
|
+
var _dec$3, _dec2$3, _class$3;
|
|
34
|
+
let AopMethodLog = (_dec$3 = AopMethod({
|
|
10
35
|
level: 'info'
|
|
11
|
-
}), _dec2$
|
|
36
|
+
}), _dec2$3 = BeanInfo({
|
|
12
37
|
module: "a-logger"
|
|
13
|
-
}), _dec$
|
|
38
|
+
}), _dec$3(_class$3 = _dec2$3(_class$3 = class AopMethodLog extends BeanAopMethodBase {
|
|
14
39
|
get(options, next, receiver, prop) {
|
|
15
40
|
const context = this._getContext(options, receiver);
|
|
16
41
|
const message = `${receiver[SymbolBeanFullName]}#${prop}(get)`;
|
|
@@ -78,7 +103,9 @@ let AopMethodLog = (_dec$4 = AopMethod({
|
|
|
78
103
|
}
|
|
79
104
|
}
|
|
80
105
|
_getContext(options, receiver) {
|
|
81
|
-
return evaluateExpressions(options.context,
|
|
106
|
+
return evaluateExpressions(options.context, {
|
|
107
|
+
self: receiver
|
|
108
|
+
});
|
|
82
109
|
}
|
|
83
110
|
_logResult(profiler, context, res, options, message) {
|
|
84
111
|
const textResult = res !== undefined ? ` result: ${JSON.stringify(res)}` : '';
|
|
@@ -98,12 +125,12 @@ let AopMethodLog = (_dec$4 = AopMethod({
|
|
|
98
125
|
if (context) info.context = context;
|
|
99
126
|
profiler.done(info);
|
|
100
127
|
}
|
|
101
|
-
}) || _class$
|
|
128
|
+
}) || _class$3) || _class$3);
|
|
102
129
|
|
|
103
|
-
var _dec$
|
|
104
|
-
let BeanLogger = (_dec$
|
|
130
|
+
var _dec$2, _dec2$2, _class$2;
|
|
131
|
+
let BeanLogger = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
|
|
105
132
|
module: "a-logger"
|
|
106
|
-
}), _dec$
|
|
133
|
+
}), _dec$2(_class$2 = _dec2$2(_class$2 = class BeanLogger extends BeanBase {
|
|
107
134
|
getLevel(clientName) {
|
|
108
135
|
return this.app.meta.logger.getLevel(clientName);
|
|
109
136
|
}
|
|
@@ -114,42 +141,17 @@ let BeanLogger = (_dec$3 = Bean(), _dec2$3 = BeanInfo({
|
|
|
114
141
|
clientName
|
|
115
142
|
});
|
|
116
143
|
}
|
|
117
|
-
}) || _class$
|
|
144
|
+
}) || _class$2) || _class$2);
|
|
118
145
|
|
|
119
|
-
var _dec$
|
|
120
|
-
let BroadcastSetLevel = (_dec$
|
|
146
|
+
var _dec$1, _dec2$1, _class$1;
|
|
147
|
+
let BroadcastSetLevel = (_dec$1 = Broadcast(), _dec2$1 = BeanInfo({
|
|
121
148
|
module: "a-logger"
|
|
122
|
-
}), _dec$
|
|
149
|
+
}), _dec$1(_class$1 = _dec2$1(_class$1 = class BroadcastSetLevel extends BeanBroadcastBase {
|
|
123
150
|
async execute(data, isEmitter) {
|
|
124
151
|
if (!isEmitter) {
|
|
125
152
|
this.app.meta.logger.setLevel(data.level, data.clientName);
|
|
126
153
|
}
|
|
127
154
|
}
|
|
128
|
-
}) || _class$2) || _class$2);
|
|
129
|
-
|
|
130
|
-
var _dec$1, _dec2$1, _class$1;
|
|
131
|
-
let MiddlewareSystemHttpLog = (_dec$1 = MiddlewareSystem(), _dec2$1 = BeanInfo({
|
|
132
|
-
module: "a-logger"
|
|
133
|
-
}), _dec$1(_class$1 = _dec2$1(_class$1 = class MiddlewareSystemHttpLog extends BeanBase {
|
|
134
|
-
async execute(_options, next) {
|
|
135
|
-
const ctx = this.ctx;
|
|
136
|
-
// start
|
|
137
|
-
const req = StdSerializers.req(ctx.req);
|
|
138
|
-
this.$loggerChild('req').http(JSON.stringify(req));
|
|
139
|
-
const profiler = this.$loggerChild('res').startTimer();
|
|
140
|
-
// next
|
|
141
|
-
await next();
|
|
142
|
-
// end
|
|
143
|
-
const res = {
|
|
144
|
-
url: ctx.req.url,
|
|
145
|
-
statusCode: ctx.res.statusCode,
|
|
146
|
-
headers: ctx.res.getHeaders()
|
|
147
|
-
};
|
|
148
|
-
profiler.done({
|
|
149
|
-
level: 'http',
|
|
150
|
-
message: JSON.stringify(res)
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
155
|
}) || _class$1) || _class$1);
|
|
154
156
|
|
|
155
157
|
var _dec, _dec2, _class;
|