vona-core 5.0.132 → 5.0.133

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 CHANGED
@@ -2178,7 +2178,7 @@ class AppLogger extends BeanSimple {
2178
2178
  name: childName
2179
2179
  });
2180
2180
  }
2181
- getLevel(clientName) {
2181
+ getFilterLevel(clientName) {
2182
2182
  clientName = clientName || 'default';
2183
2183
  const envName = `LOGGER_CLIENT_${clientName.toUpperCase()}`;
2184
2184
  const level = this.app.meta.env[envName];
@@ -2186,11 +2186,28 @@ class AppLogger extends BeanSimple {
2186
2186
  if (level === 'true' || !level) return 'info';
2187
2187
  return level;
2188
2188
  }
2189
- setLevel(level, clientName) {
2189
+ setFilterLevel(level, clientName) {
2190
2190
  clientName = clientName || 'default';
2191
2191
  const envName = `LOGGER_CLIENT_${clientName.toUpperCase()}`;
2192
2192
  this.app.meta.env[envName] = level.toString();
2193
2193
  }
2194
+ getFilterChild(clientName) {
2195
+ clientName = clientName || 'default';
2196
+ const envName = `LOGGER_CHILD_${clientName.toUpperCase()}`;
2197
+ let child = this.app.meta.env[envName];
2198
+ if (!child) {
2199
+ const envName = 'LOGGER_CHILD';
2200
+ child = this.app.meta.env[envName];
2201
+ }
2202
+ if (!child) return;
2203
+ return child.split(',');
2204
+ }
2205
+ setFilterChild(child, clientName) {
2206
+ if (Array.isArray(child)) child = child.join(',');
2207
+ clientName = clientName || 'default';
2208
+ const envName = `LOGGER_CHILD_${clientName.toUpperCase()}`;
2209
+ this.app.meta.env[envName] = child;
2210
+ }
2194
2211
  _createClient(clientName) {
2195
2212
  const configClient = this.app.config.logger.clients[clientName];
2196
2213
  if (!configClient) throw new Error(`logger client not found: ${clientName}`);
@@ -2205,7 +2222,8 @@ class AppLogger extends BeanSimple {
2205
2222
  if (typeof configClient !== 'function') return configClient;
2206
2223
  return configClient.call(this.app, {
2207
2224
  clientName,
2208
- level: () => this.getLevel(clientName)
2225
+ level: () => this.getFilterLevel(clientName),
2226
+ child: () => this.getFilterChild(clientName)
2209
2227
  }, Winston);
2210
2228
  }
2211
2229
  createTransportFile(fileName, clientInfo, options) {
@@ -2649,6 +2667,13 @@ const formatLoggerDummy = Winston.format(info => {
2649
2667
  return info;
2650
2668
  });
2651
2669
  const formatLoggerFilter = Winston.format((info, opts) => {
2670
+ // check client
2671
+ const child = typeof opts.child === 'function' ? opts.child() : opts.child;
2672
+ if (child && !child.includes(info.name)) {
2673
+ if (opts.silly && info.level === 'silly') return __formatLoggerFilterCheckInfo(info);
2674
+ return false;
2675
+ }
2676
+ // check level
2652
2677
  const level = typeof opts.level === 'function' ? opts.level() : opts.level;
2653
2678
  if (!level) return false;
2654
2679
  if (opts.strict) {
@@ -8,8 +8,10 @@ export declare class AppLogger extends BeanSimple {
8
8
  dispose(): Promise<void>;
9
9
  get(clientName?: keyof ILoggerClientRecord): Winston.Logger;
10
10
  child(childName?: keyof ILoggerChildRecord, clientName?: keyof ILoggerClientRecord): Winston.Logger;
11
- getLevel(clientName?: keyof ILoggerClientRecord): LoggerLevel | false;
12
- setLevel(level: LoggerLevel | boolean, clientName?: keyof ILoggerClientRecord): void;
11
+ getFilterLevel(clientName?: keyof ILoggerClientRecord): LoggerLevel | false;
12
+ setFilterLevel(level: LoggerLevel | boolean, clientName?: keyof ILoggerClientRecord): void;
13
+ getFilterChild(clientName?: keyof ILoggerClientRecord): string[] | undefined;
14
+ setFilterChild(child: string | string[], clientName?: keyof ILoggerClientRecord): void;
13
15
  private _createClient;
14
16
  private _prepareConfigClient;
15
17
  createTransportFile(fileName: string, clientInfo: ILoggerOptionsClientInfo, options: Winston.transports.FileTransportOptions | DailyRotateFile.DailyRotateFileTransportOptions): DailyRotateFile | Winston.transports.FileTransportInstance;
@@ -3,6 +3,13 @@ import type DailyRotateFile from 'winston-daily-rotate-file';
3
3
  export interface ILoggerOptionsClientInfo {
4
4
  clientName: keyof ILoggerClientRecord;
5
5
  level: () => (LoggerLevel | false);
6
+ child: () => (string[] | undefined);
7
+ }
8
+ export interface ILoggerFormatFilterOpts {
9
+ level: (() => (LoggerLevel | false)) | (LoggerLevel | false);
10
+ child: (() => (string[] | undefined)) | (string[] | undefined);
11
+ strict?: boolean;
12
+ silly?: boolean;
6
13
  }
7
14
  export type TypeLoggerOptions = Winston.LoggerOptions | ((clientInfo: ILoggerOptionsClientInfo, winston: typeof Winston) => Winston.LoggerOptions);
8
15
  export type TypeLoggerRotateOptions = DailyRotateFile.DailyRotateFileTransportOptions & {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-core",
3
3
  "type": "module",
4
- "version": "5.0.132",
4
+ "version": "5.0.133",
5
5
  "description": "vona",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -32,7 +32,7 @@
32
32
  "@cabloy/module-info": "^1.3.41",
33
33
  "@cabloy/module-info-pro": "^1.0.45",
34
34
  "@cabloy/type-fest": "^5.3.1",
35
- "@cabloy/utils": "^2.0.18",
35
+ "@cabloy/utils": "^2.0.22",
36
36
  "@cabloy/word-utils": "^2.0.2",
37
37
  "@cabloy/zod-errors-custom": "^2.0.6",
38
38
  "@cabloy/zod-openapi": "^1.0.8",