@eggjs/logrotator 5.0.0-beta.33 → 5.0.0-beta.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.
- package/README.md +18 -29
- package/README.zh-CN.md +0 -6
- package/dist/index.d.ts +17 -2
- package/dist/index.js +22 -3
- package/package.json +7 -13
package/README.md
CHANGED
|
@@ -13,36 +13,25 @@
|
|
|
13
13
|
|
|
14
14
|
LogRotator for egg. Rotate all file of `app.loggers` by default
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npm i @eggjs/logrotator
|
|
20
|
-
```
|
|
16
|
+
egg built-in plugin `logrotator` is enabled by default.
|
|
21
17
|
|
|
22
18
|
## Usage
|
|
23
19
|
|
|
24
|
-
- `
|
|
25
|
-
|
|
26
|
-
```js
|
|
27
|
-
exports.logrotator = {
|
|
28
|
-
enable: true,
|
|
29
|
-
package: '@eggjs/logrotator',
|
|
30
|
-
};
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
- `config.default.js`
|
|
20
|
+
- `config/config.default.ts`
|
|
34
21
|
|
|
35
|
-
```
|
|
22
|
+
```ts
|
|
36
23
|
// if any files need rotate by file size, config here
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
24
|
+
export default {
|
|
25
|
+
logrotator: {
|
|
26
|
+
filesRotateByHour: [], // list of files that will be rotated by hour
|
|
27
|
+
hourDelimiter: '-', // rotate the file by hour use specified delimiter
|
|
28
|
+
filesRotateBySize: [], // list of files that will be rotated by size
|
|
29
|
+
maxFileSize: 50 * 1024 * 1024, // Max file size to judge if any file need rotate
|
|
30
|
+
maxFiles: 10, // pieces rotate by size
|
|
31
|
+
rotateDuration: 60000, // time interval to judge if any file need rotate
|
|
32
|
+
maxDays: 31, // keep max days log files, default is `31`. Set `0` to keep all logs
|
|
33
|
+
gzip: false, // use gzip compress logger on rotate file, default is `false`. Set `true` to enable
|
|
34
|
+
},
|
|
46
35
|
};
|
|
47
36
|
```
|
|
48
37
|
|
|
@@ -72,9 +61,9 @@ If `file` is relative path, then will normalize to `path.join(this.app.config.lo
|
|
|
72
61
|
|
|
73
62
|
You can use `app.LogRotator` to customize.
|
|
74
63
|
|
|
75
|
-
```
|
|
76
|
-
// app/schedule/custom.
|
|
77
|
-
|
|
64
|
+
```ts
|
|
65
|
+
// app/schedule/custom.ts
|
|
66
|
+
export default (app: Application) => {
|
|
78
67
|
const rotator = getRotator(app);
|
|
79
68
|
return {
|
|
80
69
|
// https://github.com/eggjs/egg-schedule
|
|
@@ -88,7 +77,7 @@ module.exports = app => {
|
|
|
88
77
|
};
|
|
89
78
|
};
|
|
90
79
|
|
|
91
|
-
function getRotator(app) {
|
|
80
|
+
function getRotator(app: Application) {
|
|
92
81
|
class CustomRotator extends app.LogRotator {
|
|
93
82
|
// return map that contains a pair of srcPath and targetPath
|
|
94
83
|
// LogRotator will rename ksrcPath to targetPath
|
package/README.zh-CN.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
import './config/config.default.ts';
|
|
2
|
-
import './app/extend/application.ts';
|
|
3
1
|
import './types.ts';
|
|
2
|
+
import { type EggPluginFactory } from 'egg';
|
|
3
|
+
/**
|
|
4
|
+
* LogRotator plugin
|
|
5
|
+
*
|
|
6
|
+
* @since 4.1.0
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```ts
|
|
9
|
+
* // config/plugin.ts
|
|
10
|
+
* import logrotatorPlugin from '@eggjs/logrotator';
|
|
11
|
+
*
|
|
12
|
+
* export default {
|
|
13
|
+
* ...logrotatorPlugin(),
|
|
14
|
+
* };
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare const _default: EggPluginFactory;
|
|
18
|
+
export default _default;
|
|
4
19
|
export * from './lib/rotator.ts';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
import "./config/config.default.js";
|
|
2
|
-
import "./app/extend/application.js";
|
|
3
1
|
import "./types.js";
|
|
2
|
+
import { definePluginFactory } from 'egg';
|
|
3
|
+
/**
|
|
4
|
+
* LogRotator plugin
|
|
5
|
+
*
|
|
6
|
+
* @since 4.1.0
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```ts
|
|
9
|
+
* // config/plugin.ts
|
|
10
|
+
* import logrotatorPlugin from '@eggjs/logrotator';
|
|
11
|
+
*
|
|
12
|
+
* export default {
|
|
13
|
+
* ...logrotatorPlugin(),
|
|
14
|
+
* };
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export default definePluginFactory({
|
|
18
|
+
name: 'logrotator',
|
|
19
|
+
enable: true,
|
|
20
|
+
path: import.meta.dirname,
|
|
21
|
+
dependencies: ['schedule'],
|
|
22
|
+
});
|
|
4
23
|
export * from "./lib/rotator.js";
|
|
5
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxZQUFZLENBQUM7QUFFcEIsT0FBTyxFQUFFLG1CQUFtQixFQUF5QixNQUFNLEtBQUssQ0FBQztBQUVqRTs7Ozs7Ozs7Ozs7OztHQWFHO0FBQ0gsZUFBZSxtQkFBbUIsQ0FBQztJQUNqQyxJQUFJLEVBQUUsWUFBWTtJQUNsQixNQUFNLEVBQUUsSUFBSTtJQUNaLElBQUksRUFBRSxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU87SUFDekIsWUFBWSxFQUFFLENBQUMsVUFBVSxDQUFDO0NBQzNCLENBQXFCLENBQUM7QUFFdkIsY0FBYyxrQkFBa0IsQ0FBQyJ9
|
package/package.json
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eggjs/logrotator",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.34",
|
|
4
4
|
"description": "logrotator for egg",
|
|
5
|
-
"eggPlugin": {
|
|
6
|
-
"name": "logrotator",
|
|
7
|
-
"dependencies": [
|
|
8
|
-
"schedule"
|
|
9
|
-
]
|
|
10
|
-
},
|
|
11
5
|
"keywords": [
|
|
12
6
|
"egg",
|
|
13
7
|
"eggPlugin",
|
|
@@ -58,7 +52,7 @@
|
|
|
58
52
|
"utility": "^2.5.0"
|
|
59
53
|
},
|
|
60
54
|
"peerDependencies": {
|
|
61
|
-
"egg": "4.1.0-beta.
|
|
55
|
+
"egg": "4.1.0-beta.34"
|
|
62
56
|
},
|
|
63
57
|
"devDependencies": {
|
|
64
58
|
"@types/node": "^24.9.1",
|
|
@@ -66,11 +60,11 @@
|
|
|
66
60
|
"glob": "^11.0.0",
|
|
67
61
|
"tsdown": "0.15.11",
|
|
68
62
|
"typescript": "^5.9.3",
|
|
69
|
-
"vitest": "4.0.
|
|
70
|
-
"@eggjs/
|
|
71
|
-
"@eggjs/
|
|
72
|
-
"
|
|
73
|
-
"
|
|
63
|
+
"vitest": "4.0.5",
|
|
64
|
+
"@eggjs/mock": "7.0.0-beta.34",
|
|
65
|
+
"@eggjs/schedule": "6.0.0-beta.34",
|
|
66
|
+
"egg": "4.1.0-beta.34",
|
|
67
|
+
"@eggjs/tsconfig": "3.1.0-beta.34"
|
|
74
68
|
},
|
|
75
69
|
"files": [
|
|
76
70
|
"dist"
|