@anjianshi/utils 3.8.3 → 3.8.5
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import util from 'node:util';
|
|
1
2
|
import { type LogInfo, LogLevel, LogHandler } from '../../logging/index.js';
|
|
2
3
|
/**
|
|
3
4
|
* 向 console 输出日志
|
|
@@ -37,6 +38,7 @@ export interface FileHandlerOptions {
|
|
|
37
38
|
maxLength: number;
|
|
38
39
|
flushLength: number;
|
|
39
40
|
flushInterval: number;
|
|
41
|
+
format: util.InspectOptions;
|
|
40
42
|
}
|
|
41
43
|
export declare class FileHandler extends LogHandler {
|
|
42
44
|
readonly options: FileHandlerOptions;
|
|
@@ -69,6 +69,7 @@ export class FileHandler extends LogHandler {
|
|
|
69
69
|
maxLength: 10000,
|
|
70
70
|
flushLength: 100000,
|
|
71
71
|
flushInterval: 1000,
|
|
72
|
+
format: {},
|
|
72
73
|
...(options ?? {}),
|
|
73
74
|
};
|
|
74
75
|
this.initLogDir();
|
|
@@ -105,7 +106,7 @@ export class FileHandler extends LogHandler {
|
|
|
105
106
|
if (typeof item === 'string')
|
|
106
107
|
item = item.replace(/\x1b\[\d+m/g, '');
|
|
107
108
|
// 利用 util.format() 获得和 console.log() 相同的输出(因为 console.log() 底层也是用的 util.format())
|
|
108
|
-
return util.format
|
|
109
|
+
return util.formatWithOptions(this.options.format, item);
|
|
109
110
|
}
|
|
110
111
|
// Handle buffer & flush
|
|
111
112
|
buffer = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anjianshi/utils",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.5",
|
|
4
4
|
"description": "Common JavaScript Utils",
|
|
5
5
|
"homepage": "https://github.com/anjianshi/js-packages/utils",
|
|
6
6
|
"bugs": {
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"redis": "^5.5.6",
|
|
39
39
|
"typescript": "^5.8.3",
|
|
40
40
|
"vconsole": "^3.15.1",
|
|
41
|
+
"@anjianshi/presets-eslint-typescript": "6.1.2",
|
|
41
42
|
"@anjianshi/presets-eslint-node": "6.1.2",
|
|
43
|
+
"@anjianshi/presets-eslint-base": "6.1.2",
|
|
42
44
|
"@anjianshi/presets-eslint-react": "6.1.3",
|
|
43
|
-
"@anjianshi/presets-typescript": "3.2.5",
|
|
44
45
|
"@anjianshi/presets-prettier": "3.2.0",
|
|
45
|
-
"@anjianshi/presets-
|
|
46
|
-
"@anjianshi/presets-eslint-typescript": "6.1.2"
|
|
46
|
+
"@anjianshi/presets-typescript": "3.2.5"
|
|
47
47
|
},
|
|
48
48
|
"prettier": "@anjianshi/presets-prettier/prettierrc"
|
|
49
49
|
}
|
package/request/client.js
CHANGED
|
@@ -38,7 +38,7 @@ export class BaseRequestClient {
|
|
|
38
38
|
this.logger.warn('Retrying Request', { ...options, tryCount });
|
|
39
39
|
}
|
|
40
40
|
result = await this.realRequest(options);
|
|
41
|
-
} while (!result.success && tryCount
|
|
41
|
+
} while (!result.success && tryCount < options.retry + 1);
|
|
42
42
|
return result;
|
|
43
43
|
}
|
|
44
44
|
async realRequest(options) {
|