agora-foundation 3.9.0-alpha → 3.9.1-alpha
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/lib/logger/index.d.ts +2 -0
- package/lib/logger/index.js +3 -1
- package/lib/logger/logger-impl.d.ts +1 -0
- package/lib/logger/logger-impl.js +2 -1
- package/lib/logger/type.d.ts +1 -1
- package/lib/utilities/env.d.ts +3 -1
- package/lib/utilities/env.js +8 -1
- package/lib/utilities/logger.d.ts +5 -2
- package/lib/utilities/logger.js +16 -5
- package/lib/worker/handler/log-rotate-new.js +7 -1
- package/lib/worker/handler/log.d.ts +1 -1
- package/lib/worker/handler/log.js +5 -2
- package/lib/worker/interactor.d.ts +1 -1
- package/lib/worker/interactor.js +3 -3
- package/lib/worker/worker-installer.js +3 -2
- package/lib-es/logger/index.js +3 -1
- package/lib-es/logger/logger-impl.js +2 -1
- package/lib-es/utilities/env.js +7 -0
- package/lib-es/utilities/logger.js +16 -5
- package/lib-es/worker/handler/log-rotate-new.js +7 -1
- package/lib-es/worker/handler/log.js +5 -2
- package/lib-es/worker/interactor.js +3 -3
- package/lib-es/worker/worker-installer.js +3 -2
- package/package.json +2 -2
package/lib/logger/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LogLevel, Logger, LogManager } from './type';
|
|
2
2
|
export declare const getLogger: (opts?: {
|
|
3
3
|
label?: string;
|
|
4
|
+
maxSize?: number;
|
|
4
5
|
}) => Logger;
|
|
5
6
|
export declare const createLogger: (opts?: {
|
|
6
7
|
label?: string;
|
|
@@ -8,6 +9,7 @@ export declare const createLogger: (opts?: {
|
|
|
8
9
|
database?: boolean;
|
|
9
10
|
console?: boolean;
|
|
10
11
|
maxFiles?: number;
|
|
12
|
+
maxSize?: number;
|
|
11
13
|
}) => Logger;
|
|
12
14
|
export declare const getLogManager: () => LogManager;
|
|
13
15
|
export declare const setLogLevel: (_logLevel: LogLevel) => void;
|
package/lib/logger/index.js
CHANGED
|
@@ -50,7 +50,9 @@ var getLogger = exports.getLogger = function getLogger() {
|
|
|
50
50
|
var label = opts.label || 'agora-default';
|
|
51
51
|
if (!_common.loggerRegistrar.has(label)) {
|
|
52
52
|
_common.loggerLabels.add(label);
|
|
53
|
-
_common.loggerRegistrar.set(label, new _loggerImpl.LoggerImpl(label, {
|
|
53
|
+
_common.loggerRegistrar.set(label, new _loggerImpl.LoggerImpl(label, {
|
|
54
|
+
maxSize: opts.maxSize
|
|
55
|
+
}, {
|
|
54
56
|
console: true,
|
|
55
57
|
database: true
|
|
56
58
|
}, logLevel, (0, _worker.getWorkerSingleton)()));
|
|
@@ -34,7 +34,8 @@ var LoggerImpl = exports.LoggerImpl = /*#__PURE__*/function () {
|
|
|
34
34
|
app = _window$require.app;
|
|
35
35
|
var logFolderPath = path.resolve(app.getPath('logs'), 'logs');
|
|
36
36
|
var maxFiles = _opts.maxFiles || 5;
|
|
37
|
-
|
|
37
|
+
var maxSize = _opts.maxSize || 512;
|
|
38
|
+
_logWorkerInteractor.addFsLogger(_label, logFolderPath, maxFiles, maxSize);
|
|
38
39
|
} else {
|
|
39
40
|
this.warn('window.require is not present, logWorkerInteractor.addFsLogger cannot proceed');
|
|
40
41
|
}
|
package/lib/logger/type.d.ts
CHANGED
|
@@ -22,5 +22,5 @@ export interface LogWorkerInteractor {
|
|
|
22
22
|
lastId: number;
|
|
23
23
|
}>;
|
|
24
24
|
deleteLogs(labels: string[], lastId: number): Promise<void>;
|
|
25
|
-
addFsLogger(label: string, logFolderPath: string, maxFiles: number): void;
|
|
25
|
+
addFsLogger(label: string, logFolderPath: string, maxFiles: number, maxSize: number): void;
|
|
26
26
|
}
|
package/lib/utilities/env.d.ts
CHANGED
|
@@ -4,9 +4,11 @@ export declare enum FcrApplicationPlatform {
|
|
|
4
4
|
MACOS = 2,
|
|
5
5
|
WINDOWS = 3,
|
|
6
6
|
WEB_MOBILE = 6,
|
|
7
|
-
HARMONY = 7
|
|
7
|
+
HARMONY = 7,
|
|
8
|
+
LINUX = 8
|
|
8
9
|
}
|
|
9
10
|
export declare const getPlatform: () => FcrApplicationPlatform;
|
|
10
11
|
export declare const isWindows: () => boolean;
|
|
11
12
|
export declare const windowsVersion: () => string | null;
|
|
12
13
|
export declare const isMac: () => boolean;
|
|
14
|
+
export declare const isLinux: () => boolean;
|
package/lib/utilities/env.js
CHANGED
|
@@ -4,7 +4,7 @@ require("core-js/modules/es.object.define-property.js");
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.windowsVersion = exports.isWindows = exports.isMac = exports.isElectron = exports.getPlatform = exports.FcrApplicationPlatform = void 0;
|
|
7
|
+
exports.windowsVersion = exports.isWindows = exports.isMac = exports.isLinux = exports.isElectron = exports.getPlatform = exports.FcrApplicationPlatform = void 0;
|
|
8
8
|
require("core-js/modules/es.array.find.js");
|
|
9
9
|
require("core-js/modules/es.array.includes.js");
|
|
10
10
|
require("core-js/modules/es.array.index-of.js");
|
|
@@ -26,6 +26,7 @@ var FcrApplicationPlatform = exports.FcrApplicationPlatform = /*#__PURE__*/funct
|
|
|
26
26
|
FcrApplicationPlatform[FcrApplicationPlatform["WINDOWS"] = 3] = "WINDOWS";
|
|
27
27
|
FcrApplicationPlatform[FcrApplicationPlatform["WEB_MOBILE"] = 6] = "WEB_MOBILE";
|
|
28
28
|
FcrApplicationPlatform[FcrApplicationPlatform["HARMONY"] = 7] = "HARMONY";
|
|
29
|
+
FcrApplicationPlatform[FcrApplicationPlatform["LINUX"] = 8] = "LINUX";
|
|
29
30
|
return FcrApplicationPlatform;
|
|
30
31
|
}({});
|
|
31
32
|
var getPlatform = exports.getPlatform = function getPlatform() {
|
|
@@ -37,6 +38,9 @@ var getPlatform = exports.getPlatform = function getPlatform() {
|
|
|
37
38
|
}, {
|
|
38
39
|
key: 'mac',
|
|
39
40
|
value: FcrApplicationPlatform.MACOS
|
|
41
|
+
}, {
|
|
42
|
+
key: 'linux',
|
|
43
|
+
value: FcrApplicationPlatform.LINUX
|
|
40
44
|
}];
|
|
41
45
|
var platform = platforms.find(function (p) {
|
|
42
46
|
return userAgent.includes(p.key);
|
|
@@ -59,4 +63,7 @@ var windowsVersion = exports.windowsVersion = function windowsVersion() {
|
|
|
59
63
|
};
|
|
60
64
|
var isMac = exports.isMac = function isMac() {
|
|
61
65
|
return getPlatform() === FcrApplicationPlatform.MACOS;
|
|
66
|
+
};
|
|
67
|
+
var isLinux = exports.isLinux = function isLinux() {
|
|
68
|
+
return getPlatform() === FcrApplicationPlatform.LINUX;
|
|
62
69
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Logger } from '../logger';
|
|
2
2
|
export declare class LoggerManager {
|
|
3
3
|
private _logger;
|
|
4
|
-
private
|
|
5
|
-
|
|
4
|
+
private _label;
|
|
5
|
+
private _maxSize?;
|
|
6
|
+
constructor({ label, maxSize }: {
|
|
6
7
|
label: string;
|
|
8
|
+
maxSize?: number;
|
|
7
9
|
});
|
|
8
10
|
getLogger(): Logger;
|
|
9
11
|
createLogger(opts: {
|
|
@@ -11,4 +13,5 @@ export declare class LoggerManager {
|
|
|
11
13
|
database?: boolean;
|
|
12
14
|
}): Logger;
|
|
13
15
|
generateLogObserver<T>(logger: Logger, callbackMethods: (keyof T | [keyof T, string[]])[]): T;
|
|
16
|
+
release(): void;
|
|
14
17
|
}
|
package/lib/utilities/logger.js
CHANGED
|
@@ -53,6 +53,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
53
53
|
var _bound = require("../decorator/bound");
|
|
54
54
|
var _logSerializer = require("../decorator/log/log-serializer");
|
|
55
55
|
var _logger = require("../logger");
|
|
56
|
+
var _common = require("../logger/common");
|
|
56
57
|
var _misc = require("./misc");
|
|
57
58
|
var _LoggerManager;
|
|
58
59
|
var _initProto;
|
|
@@ -63,12 +64,15 @@ function _setFunctionName(e, t, n) { "symbol" == _typeof(t) && (t = (t = t.descr
|
|
|
63
64
|
function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? _typeof(e) : "null")); return e; }
|
|
64
65
|
var LoggerManager = exports.LoggerManager = /*#__PURE__*/function () {
|
|
65
66
|
function LoggerManager(_ref) {
|
|
66
|
-
var label = _ref.label
|
|
67
|
+
var label = _ref.label,
|
|
68
|
+
maxSize = _ref.maxSize;
|
|
67
69
|
(0, _classCallCheck2["default"])(this, LoggerManager);
|
|
68
70
|
(0, _defineProperty2["default"])(this, "_logger", void _initProto(this));
|
|
69
|
-
this.
|
|
71
|
+
this._label = label;
|
|
72
|
+
this._maxSize = maxSize;
|
|
70
73
|
this._logger = (0, _logger.getLogger)({
|
|
71
|
-
label: this.
|
|
74
|
+
label: this._label,
|
|
75
|
+
maxSize: this._maxSize
|
|
72
76
|
});
|
|
73
77
|
}
|
|
74
78
|
return (0, _createClass2["default"])(LoggerManager, [{
|
|
@@ -80,9 +84,10 @@ var LoggerManager = exports.LoggerManager = /*#__PURE__*/function () {
|
|
|
80
84
|
key: "createLogger",
|
|
81
85
|
value: function createLogger(opts) {
|
|
82
86
|
return (0, _logger.createLogger)({
|
|
83
|
-
label: this.
|
|
87
|
+
label: this._label,
|
|
84
88
|
prefix: "".concat(opts.prefix, "@").concat((0, _misc.randomString)(5)),
|
|
85
|
-
database: opts.database
|
|
89
|
+
database: opts.database,
|
|
90
|
+
maxSize: this._maxSize
|
|
86
91
|
});
|
|
87
92
|
}
|
|
88
93
|
}, {
|
|
@@ -107,6 +112,12 @@ var LoggerManager = exports.LoggerManager = /*#__PURE__*/function () {
|
|
|
107
112
|
});
|
|
108
113
|
return observer;
|
|
109
114
|
}
|
|
115
|
+
}, {
|
|
116
|
+
key: "release",
|
|
117
|
+
value: function release() {
|
|
118
|
+
_common.loggerLabels["delete"](this._label);
|
|
119
|
+
_common.loggerRegistrar["delete"](this._label);
|
|
120
|
+
}
|
|
110
121
|
}]);
|
|
111
122
|
}();
|
|
112
123
|
_LoggerManager = LoggerManager;
|
|
@@ -98,8 +98,14 @@ var createRotateTransport = exports.createRotateTransport = function createRotat
|
|
|
98
98
|
this.currentStream.end();
|
|
99
99
|
}
|
|
100
100
|
var filename = this.generateLogFilename();
|
|
101
|
-
this.currentFile = this.path.join(this.logFolderPath, filename);
|
|
101
|
+
this.currentFile = this.path.join(this.logFolderPath, this.filenamePrefix, filename);
|
|
102
102
|
console.log("[CustomRotateTransport] Creating new log file: ".concat(this.currentFile));
|
|
103
|
+
var dirPath = this.path.dirname(this.currentFile);
|
|
104
|
+
if (!this.fs.existsSync(dirPath)) {
|
|
105
|
+
this.fs.mkdirSync(dirPath, {
|
|
106
|
+
recursive: true
|
|
107
|
+
});
|
|
108
|
+
}
|
|
103
109
|
this.currentStream = this.fs.createWriteStream(this.currentFile, {
|
|
104
110
|
flags: 'a'
|
|
105
111
|
});
|
|
@@ -10,6 +10,6 @@ export declare const writeLog: (self: WorkerContext, callId: number, log: Log) =
|
|
|
10
10
|
export declare const collectLogs: (self: WorkerContext, callId: number, labels: string[]) => Promise<void>;
|
|
11
11
|
export declare const deleteLogs: (self: WorkerContext, callId: number, labels: string[], lastId: number) => Promise<void>;
|
|
12
12
|
export declare const setMaxRecords: (self: WorkerContext, callId: number, max: number) => void;
|
|
13
|
-
export declare const addFsLogger: (self: WorkerContext, callId: number, label: string, logFolderPath: string, maxFiles: number) => void;
|
|
13
|
+
export declare const addFsLogger: (self: WorkerContext, callId: number, label: string, logFolderPath: string, maxFiles: number, maxSize: number) => void;
|
|
14
14
|
export declare const writeLogsToDisk: (logs: LogSchema[]) => void;
|
|
15
15
|
export {};
|
|
@@ -272,8 +272,10 @@ var setMaxRecords = exports.setMaxRecords = function setMaxRecords(self, callId,
|
|
|
272
272
|
isSuccess: true
|
|
273
273
|
});
|
|
274
274
|
};
|
|
275
|
-
var addFsLogger = exports.addFsLogger = function addFsLogger(self, callId, label, logFolderPath, maxFiles) {
|
|
275
|
+
var addFsLogger = exports.addFsLogger = function addFsLogger(self, callId, label, logFolderPath, maxFiles, maxSize) {
|
|
276
276
|
var winston = require('winston');
|
|
277
|
+
var KB = 1024;
|
|
278
|
+
var maxSizeInKB = maxSize * KB;
|
|
277
279
|
if (!winston.loggers.has(label)) {
|
|
278
280
|
console.log("[worker] add fs logger, label: ".concat(label));
|
|
279
281
|
winston.loggers.add(label, {
|
|
@@ -282,7 +284,8 @@ var addFsLogger = exports.addFsLogger = function addFsLogger(self, callId, label
|
|
|
282
284
|
return "".concat(message);
|
|
283
285
|
}),
|
|
284
286
|
transports: [(0, _logRotateNew.createRotateTransport)("".concat(label), logFolderPath, {
|
|
285
|
-
maxFiles: maxFiles
|
|
287
|
+
maxFiles: maxFiles,
|
|
288
|
+
maxSize: maxSizeInKB
|
|
286
289
|
})]
|
|
287
290
|
});
|
|
288
291
|
}
|
|
@@ -3,7 +3,7 @@ export declare class WorkerInteractor implements LogWorkerInteractor {
|
|
|
3
3
|
private _eventEmitter;
|
|
4
4
|
private _logWorker;
|
|
5
5
|
constructor();
|
|
6
|
-
addFsLogger(label: string, logFolderPath: string, maxFiles: number): Promise<void>;
|
|
6
|
+
addFsLogger(label: string, logFolderPath: string, maxFiles: number, maxSize: number): Promise<void>;
|
|
7
7
|
clearTempLogs(): Promise<void>;
|
|
8
8
|
setMaxRecords(maxRecords: number): Promise<void>;
|
|
9
9
|
sendLog(message: string, label: string): void;
|
package/lib/worker/interactor.js
CHANGED
|
@@ -79,16 +79,16 @@ var WorkerInteractor = exports.WorkerInteractor = /*#__PURE__*/function () {
|
|
|
79
79
|
}
|
|
80
80
|
return (0, _createClass2["default"])(WorkerInteractor, [{
|
|
81
81
|
key: "addFsLogger",
|
|
82
|
-
value: function addFsLogger(label, logFolderPath, maxFiles) {
|
|
82
|
+
value: function addFsLogger(label, logFolderPath, maxFiles, maxSize) {
|
|
83
83
|
try {
|
|
84
84
|
// console.info(`[WorkerInteractor] add fs logger, label: ${label}`);
|
|
85
|
-
|
|
86
85
|
return this._promisify({
|
|
87
86
|
type: _constants.WorkerDirectives.ADD_FS_LOGGER,
|
|
88
87
|
data: {
|
|
89
88
|
label: label,
|
|
90
89
|
logFolderPath: logFolderPath,
|
|
91
|
-
maxFiles: maxFiles
|
|
90
|
+
maxFiles: maxFiles,
|
|
91
|
+
maxSize: maxSize
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
94
|
} catch (err) {
|
|
@@ -34,8 +34,9 @@ var installHandler = exports.installHandler = function installHandler(self) {
|
|
|
34
34
|
var _evt$data$data2 = evt.data.data,
|
|
35
35
|
_label = _evt$data$data2.label,
|
|
36
36
|
logFolderPath = _evt$data$data2.logFolderPath,
|
|
37
|
-
maxFiles = _evt$data$data2.maxFiles
|
|
38
|
-
|
|
37
|
+
maxFiles = _evt$data$data2.maxFiles,
|
|
38
|
+
maxSize = _evt$data$data2.maxSize;
|
|
39
|
+
(0, _log.addFsLogger)(self, callId, _label, logFolderPath, maxFiles, maxSize);
|
|
39
40
|
} else if (type === _constants.WorkerDirectives.SET_MAX_RECORDS) {
|
|
40
41
|
(0, _log.setMaxRecords)(self, callId, evt.data.data.maxRecords || 50000);
|
|
41
42
|
} else if (type === _constants.WorkerDirectives.COLLECT_LOGS) {
|
package/lib-es/logger/index.js
CHANGED
|
@@ -15,7 +15,9 @@ export var getLogger = function getLogger() {
|
|
|
15
15
|
var label = opts.label || 'agora-default';
|
|
16
16
|
if (!loggerRegistrar.has(label)) {
|
|
17
17
|
loggerLabels.add(label);
|
|
18
|
-
loggerRegistrar.set(label, new LoggerImpl(label, {
|
|
18
|
+
loggerRegistrar.set(label, new LoggerImpl(label, {
|
|
19
|
+
maxSize: opts.maxSize
|
|
20
|
+
}, {
|
|
19
21
|
console: true,
|
|
20
22
|
database: true
|
|
21
23
|
}, logLevel, getWorkerSingleton()));
|
|
@@ -26,7 +26,8 @@ export var LoggerImpl = /*#__PURE__*/function () {
|
|
|
26
26
|
app = _window$require.app;
|
|
27
27
|
var logFolderPath = path.resolve(app.getPath('logs'), 'logs');
|
|
28
28
|
var maxFiles = _opts.maxFiles || 5;
|
|
29
|
-
|
|
29
|
+
var maxSize = _opts.maxSize || 512;
|
|
30
|
+
_logWorkerInteractor.addFsLogger(_label, logFolderPath, maxFiles, maxSize);
|
|
30
31
|
} else {
|
|
31
32
|
this.warn('window.require is not present, logWorkerInteractor.addFsLogger cannot proceed');
|
|
32
33
|
}
|
package/lib-es/utilities/env.js
CHANGED
|
@@ -19,6 +19,7 @@ export var FcrApplicationPlatform = /*#__PURE__*/function (FcrApplicationPlatfor
|
|
|
19
19
|
FcrApplicationPlatform[FcrApplicationPlatform["WINDOWS"] = 3] = "WINDOWS";
|
|
20
20
|
FcrApplicationPlatform[FcrApplicationPlatform["WEB_MOBILE"] = 6] = "WEB_MOBILE";
|
|
21
21
|
FcrApplicationPlatform[FcrApplicationPlatform["HARMONY"] = 7] = "HARMONY";
|
|
22
|
+
FcrApplicationPlatform[FcrApplicationPlatform["LINUX"] = 8] = "LINUX";
|
|
22
23
|
return FcrApplicationPlatform;
|
|
23
24
|
}({});
|
|
24
25
|
export var getPlatform = function getPlatform() {
|
|
@@ -30,6 +31,9 @@ export var getPlatform = function getPlatform() {
|
|
|
30
31
|
}, {
|
|
31
32
|
key: 'mac',
|
|
32
33
|
value: FcrApplicationPlatform.MACOS
|
|
34
|
+
}, {
|
|
35
|
+
key: 'linux',
|
|
36
|
+
value: FcrApplicationPlatform.LINUX
|
|
33
37
|
}];
|
|
34
38
|
var platform = platforms.find(function (p) {
|
|
35
39
|
return userAgent.includes(p.key);
|
|
@@ -52,4 +56,7 @@ export var windowsVersion = function windowsVersion() {
|
|
|
52
56
|
};
|
|
53
57
|
export var isMac = function isMac() {
|
|
54
58
|
return getPlatform() === FcrApplicationPlatform.MACOS;
|
|
59
|
+
};
|
|
60
|
+
export var isLinux = function isLinux() {
|
|
61
|
+
return getPlatform() === FcrApplicationPlatform.LINUX;
|
|
55
62
|
};
|
|
@@ -53,15 +53,19 @@ function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side
|
|
|
53
53
|
import { bound } from '../decorator/bound';
|
|
54
54
|
import { serializeArgs } from '../decorator/log/log-serializer';
|
|
55
55
|
import { getLogger as _getLogger, createLogger as _createLogger } from '../logger';
|
|
56
|
+
import { loggerLabels, loggerRegistrar } from '../logger/common';
|
|
56
57
|
import { randomString } from './misc';
|
|
57
58
|
export var LoggerManager = /*#__PURE__*/function () {
|
|
58
59
|
function LoggerManager(_ref) {
|
|
59
|
-
var label = _ref.label
|
|
60
|
+
var label = _ref.label,
|
|
61
|
+
maxSize = _ref.maxSize;
|
|
60
62
|
_classCallCheck(this, LoggerManager);
|
|
61
63
|
_defineProperty(this, "_logger", void _initProto(this));
|
|
62
|
-
this.
|
|
64
|
+
this._label = label;
|
|
65
|
+
this._maxSize = maxSize;
|
|
63
66
|
this._logger = _getLogger({
|
|
64
|
-
label: this.
|
|
67
|
+
label: this._label,
|
|
68
|
+
maxSize: this._maxSize
|
|
65
69
|
});
|
|
66
70
|
}
|
|
67
71
|
return _createClass(LoggerManager, [{
|
|
@@ -73,9 +77,10 @@ export var LoggerManager = /*#__PURE__*/function () {
|
|
|
73
77
|
key: "createLogger",
|
|
74
78
|
value: function createLogger(opts) {
|
|
75
79
|
return _createLogger({
|
|
76
|
-
label: this.
|
|
80
|
+
label: this._label,
|
|
77
81
|
prefix: "".concat(opts.prefix, "@").concat(randomString(5)),
|
|
78
|
-
database: opts.database
|
|
82
|
+
database: opts.database,
|
|
83
|
+
maxSize: this._maxSize
|
|
79
84
|
});
|
|
80
85
|
}
|
|
81
86
|
}, {
|
|
@@ -100,6 +105,12 @@ export var LoggerManager = /*#__PURE__*/function () {
|
|
|
100
105
|
});
|
|
101
106
|
return observer;
|
|
102
107
|
}
|
|
108
|
+
}, {
|
|
109
|
+
key: "release",
|
|
110
|
+
value: function release() {
|
|
111
|
+
loggerLabels["delete"](this._label);
|
|
112
|
+
loggerRegistrar["delete"](this._label);
|
|
113
|
+
}
|
|
103
114
|
}]);
|
|
104
115
|
}();
|
|
105
116
|
_LoggerManager = LoggerManager;
|
|
@@ -90,8 +90,14 @@ export var createRotateTransport = function createRotateTransport(filenamePrefix
|
|
|
90
90
|
this.currentStream.end();
|
|
91
91
|
}
|
|
92
92
|
var filename = this.generateLogFilename();
|
|
93
|
-
this.currentFile = this.path.join(this.logFolderPath, filename);
|
|
93
|
+
this.currentFile = this.path.join(this.logFolderPath, this.filenamePrefix, filename);
|
|
94
94
|
console.log("[CustomRotateTransport] Creating new log file: ".concat(this.currentFile));
|
|
95
|
+
var dirPath = this.path.dirname(this.currentFile);
|
|
96
|
+
if (!this.fs.existsSync(dirPath)) {
|
|
97
|
+
this.fs.mkdirSync(dirPath, {
|
|
98
|
+
recursive: true
|
|
99
|
+
});
|
|
100
|
+
}
|
|
95
101
|
this.currentStream = this.fs.createWriteStream(this.currentFile, {
|
|
96
102
|
flags: 'a'
|
|
97
103
|
});
|
|
@@ -265,8 +265,10 @@ export var setMaxRecords = function setMaxRecords(self, callId, max) {
|
|
|
265
265
|
isSuccess: true
|
|
266
266
|
});
|
|
267
267
|
};
|
|
268
|
-
export var addFsLogger = function addFsLogger(self, callId, label, logFolderPath, maxFiles) {
|
|
268
|
+
export var addFsLogger = function addFsLogger(self, callId, label, logFolderPath, maxFiles, maxSize) {
|
|
269
269
|
var winston = require('winston');
|
|
270
|
+
var KB = 1024;
|
|
271
|
+
var maxSizeInKB = maxSize * KB;
|
|
270
272
|
if (!winston.loggers.has(label)) {
|
|
271
273
|
console.log("[worker] add fs logger, label: ".concat(label));
|
|
272
274
|
winston.loggers.add(label, {
|
|
@@ -275,7 +277,8 @@ export var addFsLogger = function addFsLogger(self, callId, label, logFolderPath
|
|
|
275
277
|
return "".concat(message);
|
|
276
278
|
}),
|
|
277
279
|
transports: [createRotateTransport("".concat(label), logFolderPath, {
|
|
278
|
-
maxFiles: maxFiles
|
|
280
|
+
maxFiles: maxFiles,
|
|
281
|
+
maxSize: maxSizeInKB
|
|
279
282
|
})]
|
|
280
283
|
});
|
|
281
284
|
}
|
|
@@ -71,16 +71,16 @@ export var WorkerInteractor = /*#__PURE__*/function () {
|
|
|
71
71
|
}
|
|
72
72
|
return _createClass(WorkerInteractor, [{
|
|
73
73
|
key: "addFsLogger",
|
|
74
|
-
value: function addFsLogger(label, logFolderPath, maxFiles) {
|
|
74
|
+
value: function addFsLogger(label, logFolderPath, maxFiles, maxSize) {
|
|
75
75
|
try {
|
|
76
76
|
// console.info(`[WorkerInteractor] add fs logger, label: ${label}`);
|
|
77
|
-
|
|
78
77
|
return this._promisify({
|
|
79
78
|
type: WorkerDirectives.ADD_FS_LOGGER,
|
|
80
79
|
data: {
|
|
81
80
|
label: label,
|
|
82
81
|
logFolderPath: logFolderPath,
|
|
83
|
-
maxFiles: maxFiles
|
|
82
|
+
maxFiles: maxFiles,
|
|
83
|
+
maxSize: maxSize
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
} catch (err) {
|
|
@@ -27,8 +27,9 @@ export var installHandler = function installHandler(self) {
|
|
|
27
27
|
var _evt$data$data2 = evt.data.data,
|
|
28
28
|
_label = _evt$data$data2.label,
|
|
29
29
|
logFolderPath = _evt$data$data2.logFolderPath,
|
|
30
|
-
maxFiles = _evt$data$data2.maxFiles
|
|
31
|
-
|
|
30
|
+
maxFiles = _evt$data$data2.maxFiles,
|
|
31
|
+
maxSize = _evt$data$data2.maxSize;
|
|
32
|
+
addFsLogger(self, callId, _label, logFolderPath, maxFiles, maxSize);
|
|
32
33
|
} else if (type === WorkerDirectives.SET_MAX_RECORDS) {
|
|
33
34
|
setMaxRecords(self, callId, evt.data.data.maxRecords || 50000);
|
|
34
35
|
} else if (type === WorkerDirectives.COLLECT_LOGS) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agora-foundation",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.1-alpha",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@types/jasmine": "^5.1.4",
|
|
25
25
|
"@types/lodash": "^4.14.168",
|
|
26
26
|
"@types/node": "^20.11.30",
|
|
27
|
-
"agora-toolchain": "3.9.
|
|
27
|
+
"agora-toolchain": "3.9.1-alpha",
|
|
28
28
|
"core-js": "^3.33.3",
|
|
29
29
|
"tslib": "^2.6.2",
|
|
30
30
|
"winston": "^3.16.0",
|