vona-core 5.0.82 → 5.0.84

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.
@@ -13,8 +13,8 @@ export declare class AppLogger extends BeanSimple {
13
13
  setLevel(level: LoggerLevel | boolean, clientName?: keyof ILoggerClientRecord): void;
14
14
  private _createClient;
15
15
  private _prepareConfigClient;
16
- makeTransportFile(clientInfo: ILoggerOptionsClientInfo, fileName: string, levelStrict?: LoggerLevel): DailyRotateFile | Winston.transports.FileTransportInstance;
16
+ makeTransportFile(clientInfo: ILoggerOptionsClientInfo, fileName: string, levelStrict?: LoggerLevel): DailyRotateFile | Winston.transports.FileTransportInstance | undefined;
17
17
  makeTransportConsole(clientInfo: ILoggerOptionsClientInfo): Transport | undefined;
18
- createTransportFile(fileName: string, clientInfo: ILoggerOptionsClientInfo, options: Winston.transports.FileTransportOptions | DailyRotateFile.DailyRotateFileTransportOptions): DailyRotateFile | Winston.transports.FileTransportInstance;
18
+ createTransportFile(fileName: string, clientInfo: ILoggerOptionsClientInfo, options: Winston.transports.FileTransportOptions | DailyRotateFile.DailyRotateFileTransportOptions): DailyRotateFile | Winston.transports.FileTransportInstance | undefined;
19
19
  }
20
20
  export {};
@@ -1,3 +1,5 @@
1
+ import { catchErrorSync } from '@cabloy/utils';
2
+ import fse from 'fs-extra';
1
3
  import * as Winston from 'winston';
2
4
  import DailyRotateFile from 'winston-daily-rotate-file';
3
5
  import { BeanSimple } from "../../bean/beanSimple.js";
@@ -75,6 +77,16 @@ export class AppLogger extends BeanSimple {
75
77
  });
76
78
  }
77
79
  createTransportFile(fileName, clientInfo, options) {
80
+ const dirname = this.app.config.server.loggerDir;
81
+ if (!fse.existsSync(dirname)) {
82
+ const [_, err] = catchErrorSync(() => {
83
+ fse.ensureDirSync(dirname);
84
+ });
85
+ if (err) {
86
+ console.error(`========== Logger dir not exists: ${dirname} ==========`);
87
+ return;
88
+ }
89
+ }
78
90
  const configRotate = this.app.config.logger.rotate;
79
91
  let optionsFile;
80
92
  if (configRotate.enable) {
@@ -83,7 +95,7 @@ export class AppLogger extends BeanSimple {
83
95
  else {
84
96
  optionsFile = { filename: `${fileName}.log` };
85
97
  }
86
- const _options = deepExtend({ dirname: this.app.config.server.loggerDir }, optionsFile, options);
98
+ const _options = deepExtend({ dirname }, optionsFile, options);
87
99
  if (configRotate.enable) {
88
100
  const transport = new DailyRotateFile(_options);
89
101
  transport.on('error', err => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-core",
3
3
  "type": "module",
4
- "version": "5.0.82",
4
+ "version": "5.0.84",
5
5
  "description": "vona",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -32,7 +32,7 @@
32
32
  "@cabloy/module-info": "^1.3.31",
33
33
  "@cabloy/module-info-pro": "^1.0.39",
34
34
  "@cabloy/set": "^1.0.17",
35
- "@cabloy/utils": "^1.0.46",
35
+ "@cabloy/utils": "^1.0.47",
36
36
  "@cabloy/word-utils": "^2.0.1",
37
37
  "@cabloy/zod-errors-custom": "^2.0.3",
38
38
  "@cabloy/zod-openapi": "^1.0.3",