vona-module-a-logger 5.0.33 → 5.0.34

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.
@@ -56,27 +56,38 @@ declare module 'vona' {
56
56
  }
57
57
  /** bean: end */
58
58
  /** broadcast: begin */
59
- export * from '../bean/broadcast.setLevel.ts';
59
+ export * from '../bean/broadcast.setFilterChild.ts';
60
+ export * from '../bean/broadcast.setFilterLevel.ts';
60
61
  import { type IDecoratorBroadcastOptions } from 'vona-module-a-broadcast';
61
62
  declare module 'vona-module-a-broadcast' {
62
63
  interface IBroadcastRecord {
63
- 'a-logger:setLevel': IDecoratorBroadcastOptions;
64
+ 'a-logger:setFilterChild': IDecoratorBroadcastOptions;
65
+ 'a-logger:setFilterLevel': IDecoratorBroadcastOptions;
64
66
  }
65
67
  }
66
68
  declare module 'vona-module-a-logger' {
67
- interface BroadcastSetLevel {
69
+ interface BroadcastSetFilterChild {
68
70
  }
69
- interface BroadcastSetLevel {
70
- get $beanFullName(): 'a-logger.broadcast.setLevel';
71
- get $onionName(): 'a-logger:setLevel';
71
+ interface BroadcastSetFilterChild {
72
+ get $beanFullName(): 'a-logger.broadcast.setFilterChild';
73
+ get $onionName(): 'a-logger:setFilterChild';
74
+ get $onionOptions(): IDecoratorBroadcastOptions;
75
+ }
76
+ interface BroadcastSetFilterLevel {
77
+ }
78
+ interface BroadcastSetFilterLevel {
79
+ get $beanFullName(): 'a-logger.broadcast.setFilterLevel';
80
+ get $onionName(): 'a-logger:setFilterLevel';
72
81
  get $onionOptions(): IDecoratorBroadcastOptions;
73
82
  }
74
83
  }
75
84
  /** broadcast: end */
76
85
  /** broadcast: begin */
77
- import type { BroadcastSetLevel } from '../bean/broadcast.setLevel.ts';
86
+ import type { BroadcastSetFilterChild } from '../bean/broadcast.setFilterChild.ts';
87
+ import type { BroadcastSetFilterLevel } from '../bean/broadcast.setFilterLevel.ts';
78
88
  export interface IModuleBroadcast {
79
- 'setLevel': BroadcastSetLevel;
89
+ 'setFilterChild': BroadcastSetFilterChild;
90
+ 'setFilterLevel': BroadcastSetFilterLevel;
80
91
  }
81
92
  /** broadcast: end */
82
93
  /** main: begin */
@@ -3,11 +3,13 @@ import type * as Transport from 'winston-transport';
3
3
  import { BeanBase } from 'vona';
4
4
  import * as Winston from 'winston';
5
5
  export declare class BeanLogger extends BeanBase {
6
- getLevel(clientName?: keyof ILoggerClientRecord): LoggerLevel | false;
7
- setLevel(level: LoggerLevel | boolean, clientName?: keyof ILoggerClientRecord): void;
6
+ getFilterLevel(clientName?: keyof ILoggerClientRecord): LoggerLevel | false;
7
+ setFilterLevel(level: LoggerLevel | boolean, clientName?: keyof ILoggerClientRecord): void;
8
+ getFilterChild(clientName?: keyof ILoggerClientRecord): string[] | undefined;
9
+ setFilterChild(child: string | string[], clientName?: keyof ILoggerClientRecord): void;
8
10
  get default(): Winston.Logger;
9
11
  get(clientName?: keyof ILoggerClientRecord): Winston.Logger;
10
12
  getChild(childName: keyof ILoggerChildRecord, clientName?: keyof ILoggerClientRecord): Winston.Logger;
11
- makeTransportFile(clientInfo: ILoggerOptionsClientInfo, fileName: string, levelStrict?: LoggerLevel): Transport;
13
+ makeTransportFile(clientInfo: ILoggerOptionsClientInfo, fileName: string, levelStrict?: LoggerLevel, childStrict?: string | string[]): Transport;
12
14
  makeTransportConsole(clientInfo: ILoggerOptionsClientInfo): Transport;
13
15
  }
@@ -0,0 +1,10 @@
1
+ import type { ILoggerClientRecord } from 'vona';
2
+ import type { IBroadcastExecute } from 'vona-module-a-broadcast';
3
+ import { BeanBroadcastBase } from 'vona-module-a-broadcast';
4
+ export interface TypeBroadcastSetFilterChildJobData {
5
+ child: string | string[];
6
+ clientName?: keyof ILoggerClientRecord;
7
+ }
8
+ export declare class BroadcastSetFilterChild extends BeanBroadcastBase<TypeBroadcastSetFilterChildJobData> implements IBroadcastExecute<TypeBroadcastSetFilterChildJobData> {
9
+ execute(data: TypeBroadcastSetFilterChildJobData, isEmitter?: boolean): Promise<void>;
10
+ }
@@ -0,0 +1,10 @@
1
+ import type { ILoggerClientRecord, LoggerLevel } from 'vona';
2
+ import type { IBroadcastExecute } from 'vona-module-a-broadcast';
3
+ import { BeanBroadcastBase } from 'vona-module-a-broadcast';
4
+ export interface TypeBroadcastSetFilterLevelJobData {
5
+ level: LoggerLevel | boolean;
6
+ clientName?: keyof ILoggerClientRecord;
7
+ }
8
+ export declare class BroadcastSetFilterLevel extends BeanBroadcastBase<TypeBroadcastSetFilterLevelJobData> implements IBroadcastExecute<TypeBroadcastSetFilterLevelJobData> {
9
+ execute(data: TypeBroadcastSetFilterLevelJobData, isEmitter?: boolean): Promise<void>;
10
+ }
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { BeanInfo, BeanBase, BeanAopMethodBase, SymbolBeanFullName, formatLoggerFilter, formatLoggerDummy, formatLoggerConsole, BeanSimple, combineConfigDefault, deepExtend, BeanScopeBase } from 'vona';
2
+ import { __decorate } from 'tslib';
2
3
  import StdSerializers from 'pino-std-serializers';
3
4
  import { MiddlewareSystem, AopMethod } from 'vona-module-a-aspect';
4
5
  import { evaluateExpressions } from '@cabloy/utils';
@@ -6,10 +7,7 @@ import { Bean, Scope } from 'vona-module-a-bean';
6
7
  import * as Winston from 'winston';
7
8
  import { Broadcast, BeanBroadcastBase } from 'vona-module-a-broadcast';
8
9
 
9
- var _dec$4, _dec2$4, _class$4;
10
- let MiddlewareSystemHttpLog = (_dec$4 = MiddlewareSystem(), _dec2$4 = BeanInfo({
11
- module: "a-logger"
12
- }), _dec$4(_class$4 = _dec2$4(_class$4 = class MiddlewareSystemHttpLog extends BeanBase {
10
+ let MiddlewareSystemHttpLog = class MiddlewareSystemHttpLog extends BeanBase {
13
11
  async execute(_options, next) {
14
12
  const ctx = this.ctx;
15
13
  // start
@@ -29,14 +27,12 @@ let MiddlewareSystemHttpLog = (_dec$4 = MiddlewareSystem(), _dec2$4 = BeanInfo({
29
27
  message: JSON.stringify(res)
30
28
  });
31
29
  }
32
- }) || _class$4) || _class$4);
33
-
34
- var _dec$3, _dec2$3, _class$3;
35
- let AopMethodLog = (_dec$3 = AopMethod({
36
- level: 'info'
37
- }), _dec2$3 = BeanInfo({
30
+ };
31
+ MiddlewareSystemHttpLog = __decorate([MiddlewareSystem(), BeanInfo({
38
32
  module: "a-logger"
39
- }), _dec$3(_class$3 = _dec2$3(_class$3 = class AopMethodLog extends BeanAopMethodBase {
33
+ })], MiddlewareSystemHttpLog);
34
+
35
+ let AopMethodLog = class AopMethodLog extends BeanAopMethodBase {
40
36
  get(options, next, receiver, prop) {
41
37
  const context = this._getContext(options, receiver);
42
38
  const message = `${receiver[SymbolBeanFullName]}#${prop}(get)`;
@@ -137,22 +133,34 @@ let AopMethodLog = (_dec$3 = AopMethod({
137
133
  if (context) info.context = context;
138
134
  profiler.done(info);
139
135
  }
140
- }) || _class$3) || _class$3);
141
-
142
- var _dec$2, _dec2$2, _class$2;
143
- let BeanLogger = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
136
+ };
137
+ AopMethodLog = __decorate([AopMethod({
138
+ level: 'info'
139
+ }), BeanInfo({
144
140
  module: "a-logger"
145
- }), _dec$2(_class$2 = _dec2$2(_class$2 = class BeanLogger extends BeanBase {
146
- getLevel(clientName) {
147
- return this.app.meta.logger.getLevel(clientName);
141
+ })], AopMethodLog);
142
+
143
+ let BeanLogger = class BeanLogger extends BeanBase {
144
+ getFilterLevel(clientName) {
145
+ return this.app.meta.logger.getFilterLevel(clientName);
148
146
  }
149
- setLevel(level, clientName) {
150
- this.app.meta.logger.setLevel(level, clientName);
151
- this.scope.broadcast.setLevel.emit({
147
+ setFilterLevel(level, clientName) {
148
+ this.app.meta.logger.setFilterLevel(level, clientName);
149
+ this.scope.broadcast.setFilterLevel.emit({
152
150
  level,
153
151
  clientName
154
152
  });
155
153
  }
154
+ getFilterChild(clientName) {
155
+ return this.app.meta.logger.getFilterChild(clientName);
156
+ }
157
+ setFilterChild(child, clientName) {
158
+ this.app.meta.logger.setFilterChild(child, clientName);
159
+ this.scope.broadcast.setFilterChild.emit({
160
+ child,
161
+ clientName
162
+ });
163
+ }
156
164
  get default() {
157
165
  return this.app.meta.logger.get();
158
166
  }
@@ -164,10 +172,11 @@ let BeanLogger = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
164
172
  name: childName
165
173
  });
166
174
  }
167
- makeTransportFile(clientInfo, fileName, levelStrict) {
175
+ makeTransportFile(clientInfo, fileName, levelStrict, childStrict) {
168
176
  return this.app.meta.logger.createTransportFile(fileName, clientInfo, {
169
177
  level: levelStrict ?? 'silly',
170
178
  format: Winston.format.combine(formatLoggerFilter({
179
+ child: childStrict ?? clientInfo.child,
171
180
  level: levelStrict ?? clientInfo.level,
172
181
  strict: !!levelStrict
173
182
  }), Winston.format.json())
@@ -177,26 +186,41 @@ let BeanLogger = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
177
186
  return new Winston.transports.Console({
178
187
  level: 'silly',
179
188
  format: Winston.format.combine(formatLoggerDummy(), formatLoggerFilter({
189
+ child: clientInfo.child,
180
190
  level: clientInfo.level,
181
191
  silly: true
182
192
  }), Winston.format.colorize(), formatLoggerConsole(clientInfo)),
183
193
  forceConsole: true
184
194
  });
185
195
  }
186
- }) || _class$2) || _class$2);
196
+ };
197
+ BeanLogger = __decorate([Bean(), BeanInfo({
198
+ module: "a-logger"
199
+ })], BeanLogger);
187
200
 
188
- var _dec$1, _dec2$1, _class$1;
189
- let BroadcastSetLevel = (_dec$1 = Broadcast({
190
- instance: false
191
- }), _dec2$1 = BeanInfo({
201
+ let BroadcastSetFilterChild = class BroadcastSetFilterChild extends BeanBroadcastBase {
202
+ async execute(data, isEmitter) {
203
+ if (!isEmitter) {
204
+ this.app.meta.logger.setFilterChild(data.child, data.clientName);
205
+ }
206
+ }
207
+ };
208
+ BroadcastSetFilterChild = __decorate([Broadcast(), BeanInfo({
192
209
  module: "a-logger"
193
- }), _dec$1(_class$1 = _dec2$1(_class$1 = class BroadcastSetLevel extends BeanBroadcastBase {
210
+ })], BroadcastSetFilterChild);
211
+
212
+ let BroadcastSetFilterLevel = class BroadcastSetFilterLevel extends BeanBroadcastBase {
194
213
  async execute(data, isEmitter) {
195
214
  if (!isEmitter) {
196
- this.app.meta.logger.setLevel(data.level, data.clientName);
215
+ this.app.meta.logger.setFilterLevel(data.level, data.clientName);
197
216
  }
198
217
  }
199
- }) || _class$1) || _class$1);
218
+ };
219
+ BroadcastSetFilterLevel = __decorate([Broadcast({
220
+ instance: false
221
+ }), BeanInfo({
222
+ module: "a-logger"
223
+ })], BroadcastSetFilterLevel);
200
224
 
201
225
  class Main extends BeanSimple {
202
226
  async moduleLoading() {
@@ -211,11 +235,10 @@ async function configDefault(_app) {
211
235
  return {};
212
236
  }
213
237
 
214
- var _dec, _dec2, _class;
215
- let ScopeModuleALogger = (_dec = Scope(), _dec2 = BeanInfo({
238
+ let ScopeModuleALogger = class ScopeModuleALogger extends BeanScopeBase {};
239
+ ScopeModuleALogger = __decorate([Scope(), BeanInfo({
216
240
  module: "a-logger"
217
- }), _dec(_class = _dec2(_class = class ScopeModuleALogger extends BeanScopeBase {}) || _class) || _class);
218
-
241
+ })], ScopeModuleALogger);
219
242
  /** scope: end */
220
243
 
221
- export { AopMethodLog, BeanLogger, BroadcastSetLevel, Main, MiddlewareSystemHttpLog, ScopeModuleALogger, configDefault };
244
+ export { AopMethodLog, BeanLogger, BroadcastSetFilterChild, BroadcastSetFilterLevel, Main, MiddlewareSystemHttpLog, ScopeModuleALogger, configDefault };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-a-logger",
3
3
  "type": "module",
4
- "version": "5.0.33",
4
+ "version": "5.0.34",
5
5
  "title": "a-logger",
6
6
  "vonaModule": {
7
7
  "dependencies": {},
@@ -1,10 +0,0 @@
1
- import type { ILoggerClientRecord, LoggerLevel } from 'vona';
2
- import type { IBroadcastExecute } from 'vona-module-a-broadcast';
3
- import { BeanBroadcastBase } from 'vona-module-a-broadcast';
4
- export interface TypeBroadcastSetLevelJobData {
5
- level: LoggerLevel | boolean;
6
- clientName?: keyof ILoggerClientRecord;
7
- }
8
- export declare class BroadcastSetLevel extends BeanBroadcastBase<TypeBroadcastSetLevelJobData> implements IBroadcastExecute<TypeBroadcastSetLevelJobData> {
9
- execute(data: TypeBroadcastSetLevelJobData, isEmitter?: boolean): Promise<void>;
10
- }